-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete tmpfiles #1135
Delete tmpfiles #1135
Conversation
content_harvester/by_record.py
Outdated
collection_id, | ||
request, | ||
thumbnail_src, | ||
record['calisphere-id'] | ||
) | ||
|
||
[os.remove(filepath) for filepath in tmp_files] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So one problem with this route is that tmp_files
could be undefined in the case where there's no media and no thumbnail.
Another problem is that, if there is a media file and a thumbnail, any tmp_files returned by create_media_component
will be overwritten by the tmp_files returned by create_thumbnail_component
, and won't be deleted here at line 116.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'oh, of course. How does the new commit look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but now, in the case where the media_source and the thumbnail_source are the same, you might wind up with duplicates in tmp_files
and os.remove
will throw a FileNotFoundError
when it tries to delete the same file a second time.
[os.remove(filepath) for filepath in set(tmp_files)]
would de-dupe the list, or you could explicitly check if os.path.exists(filepath)
before removing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Egads, right you are! Pushed another commit.
content_harvester/by_record.py
Outdated
collection_id, | ||
request, | ||
thumbnail_src, | ||
record['calisphere-id'] | ||
) | ||
|
||
[os.remove(filepath) for filepath in tmp_files] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but now, in the case where the media_source and the thumbnail_source are the same, you might wind up with duplicates in tmp_files
and os.remove
will throw a FileNotFoundError
when it tries to delete the same file a second time.
[os.remove(filepath) for filepath in set(tmp_files)]
would de-dupe the list, or you could explicitly check if os.path.exists(filepath)
before removing it.
No description provided.