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

check if file exists before deleting #1197

Closed
wants to merge 2 commits into from
Closed

Conversation

jmelloy
Copy link

@jmelloy jmelloy commented Dec 1, 2022

S3 was failing on first run because the files didn't exist yet, so check that they exist first.

@jschneier
Copy link
Owner

Thanks, rather than running exists, which is another query people pay for, can you just catch the exception?

@jmelloy
Copy link
Author

jmelloy commented Dec 1, 2022

Done

try:
self.bucket.Object(name).delete()
except Exception as e:
print(e)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check for whatever specific error code there might be and just silence that and re-raise otherwise.

If you check the handling in .exists() and similar you will see what I mean.

@jschneier
Copy link
Owner

Also, will need to rebase / merge due to conflicts.

@jschneier
Copy link
Owner

Fixed in #1201.

@jschneier jschneier closed this Dec 22, 2022
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.

None yet

2 participants