Skip to content

Commit 3932745

Browse files
committed
only download file if the job is supported
1 parent ae0f9d7 commit 3932745

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/bma_client_lib/bma_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,30 @@ def upload_file(self, path: Path, attribution: str, file_license: str) -> dict[s
210210
self.base_url + "/api/v1/json/files/upload/",
211211
data={"metadata": json.dumps(data)},
212212
files=files,
213+
timeout=30,
213214
)
214215
return r.json()
215216

216217
def handle_job(self, job: Job) -> None:
217218
"""Do the thing and upload the result."""
218219
# make sure the source file for the job is available
219-
source = self.download_job_source(job)
220220
# do it
221221
result: JobResult
222222
if isinstance(job, ImageConversionJob | ThumbnailJob):
223+
source = self.download_job_source(job)
223224
result = self.handle_image_conversion_job(job=job, orig=source)
224225
filename = f"{job.job_uuid}.{job.filetype.lower()}"
225226

226227
elif isinstance(job, ImageExifExtractionJob):
228+
source = self.download_job_source(job)
227229
result = self.get_exif(fname=source)
228230
filename = "exif.json"
229231

230232
elif isinstance(job, ThumbnailSourceJob):
233+
info = self.get_file_info(file_uuid=job.basefile_uuid)
234+
if info["filetype"] != "image":
235+
raise JobNotSupportedError(job=job)
236+
source = self.download_job_source(job)
231237
result = self.create_thumbnail_source(job=job)
232238
filename = job.source_filename
233239

0 commit comments

Comments
 (0)