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

clean up after ContentTooShortError #363

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Apr 29, 2024

sometimes urlretrieve will not get the whole file and raise a ContentTooShortError. it will not delete the partially downloaded file in this case, which in a later run will cause issues as "the file is already there" but "it's not a valid RPM file".

instead, catch the ContentTooShortError and try to delete the file

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Makes me wonder which other exceptions can be raised that leave a (partial) file in place

@evgeni
Copy link
Member Author

evgeni commented Apr 29, 2024

I did read https://github.com/python/cpython/blob/main/Lib/urllib/request.py before opening this PR, and from the code itself: none.
Obviously, any line could itself raise something w/o an explicit raise, but oh well…

sometimes urlretrieve will not get the whole file and raise a
ContentTooShortError. it will not delete the partially downloaded file
in this case, which in a later run will cause issues as "the file is
already there" but "it's not a valid RPM file".

instead, catch the ContentTooShortError and try to delete the file
@evgeni evgeni merged commit 1b2ff8b into master Apr 29, 2024
3 checks passed
@evgeni evgeni deleted the delete-half-downloaded branch April 29, 2024 07:56
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.

2 participants