Skip to content

Commit

Permalink
Delete tmp files from local disk
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarahui committed Oct 7, 2024
1 parent 3b12778 commit cb35b73
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions content_harvester/by_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def create_media_component(
derivative_filepath,
f"jp2/{collection_id}/{jp2_destination_filename}"
)
os.remove(derivative_filepath)
mimetype = 'image/jp2'
else:
content_s3_filepath = upload_content(
Expand All @@ -328,6 +329,7 @@ def create_media_component(
'date_content_component_created': datetime.now().isoformat()
}
}

return media_component


Expand Down Expand Up @@ -364,13 +366,15 @@ def create_thumbnail_component(
derivative_filepath, f"thumbnails/{collection_id}/{thumbnail_md5}"
)
dimensions = get_dimensions(derivative_filepath, record_context)
os.remove(derivative_filepath)
elif mapped_mimetype in ['video/mp4','video/quicktime']:
derivative_filepath = derivatives.video_to_thumb(thumbnail_tmp_filepath)
if derivative_filepath:
content_s3_filepath = upload_content(
derivative_filepath, f"thumbnails/{collection_id}/{thumbnail_md5}"
)
dimensions = get_dimensions(derivative_filepath, record_context)
os.remove(derivative_filepath)

thumbnail_component = {
'mimetype': 'image/jpeg',
Expand All @@ -384,6 +388,10 @@ def create_thumbnail_component(
'date_content_component_created': datetime.now().isoformat()
}
}

if os.path.exists(thumbnail_tmp_filepath):
os.remove(thumbnail_tmp_filepath)

return thumbnail_component


Expand Down

0 comments on commit cb35b73

Please sign in to comment.