Skip to content
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

Merged
merged 4 commits into from
Oct 16, 2024
Merged

Delete tmpfiles #1135

merged 4 commits into from
Oct 16, 2024

Conversation

barbarahui
Copy link
Collaborator

No description provided.

collection_id,
request,
thumbnail_src,
record['calisphere-id']
)

[os.remove(filepath) for filepath in tmp_files]
Copy link
Collaborator

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.

Copy link
Collaborator Author

@barbarahui barbarahui Oct 16, 2024

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

collection_id,
request,
thumbnail_src,
record['calisphere-id']
)

[os.remove(filepath) for filepath in tmp_files]
Copy link
Collaborator

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.

@barbarahui barbarahui merged commit b1a9225 into main Oct 16, 2024
2 checks passed
@barbarahui barbarahui deleted the delete_tmpfiles branch October 16, 2024 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nuxeo content_harvest issues for #26713 - OSError: [Errno 28] No space left on device
2 participants