From 9f7be231bd24dbb8b5e34e8b1c7554e59e4e5ada Mon Sep 17 00:00:00 2001 From: Barbara Hui Date: Fri, 10 May 2024 10:27:57 -0700 Subject: [PATCH] Upload image thumbnail only if get_dimensions() succeeds --- content_harvester/by_record.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content_harvester/by_record.py b/content_harvester/by_record.py index d3afaf28..7360ef48 100644 --- a/content_harvester/by_record.py +++ b/content_harvester/by_record.py @@ -108,10 +108,6 @@ def harvest_record_content( content_s3_filepath = None dimensions = None if downloaded_md5 and thumbnail.src_mime_type in ['image/jpeg', 'image/png']: - content_s3_filepath = upload_content( - thumbnail.tmp_filepath, - f"thumbnails/{collection_id}/{downloaded_md5}" - ) try: dimensions = get_dimensions( thumbnail.tmp_filepath, record['calisphere-id']) @@ -120,7 +116,11 @@ def harvest_record_content( f"Error getting dimensions for {record['calisphere-id']}: " f"{e}, continuing..." ) - + else: + content_s3_filepath = upload_content( + thumbnail.tmp_filepath, + f"thumbnails/{collection_id}/{downloaded_md5}" + ) elif downloaded_md5 and thumbnail.src_mime_type == 'application/pdf': derivative_filepath = derivatives.pdf_to_thumb(thumbnail.tmp_filepath) if derivative_filepath: