Repository navigation
Delete partial file when local download_object_range fails (#2223) - #2227
Conversation
|
Hi, I've opened a pull request for this: <#2227 >
|
micafer
left a comment
There was a problem hiding this comment.
Thanks for the fix! The implementation looks reasonable, but I think the regression test should cover a failure after some data has already been written.
Currently, the test deletes the source object before starting the download. This causes a FileNotFoundError before any data is yielded, so it doesn't actually verify cleanup of a partially downloaded file.
Could you update the test to use a generator that yields a chunk of data and then raises an exception? This would verify that the partially written destination file is removed when delete_on_failure=True.
It would also be useful to test that the partial file is preserved when delete_on_failure=False.
One minor suggestion: consider handling errors from os.remove() so they don't mask the original download exception.
…tream - Replace the previous test, which deleted the source object before the download (raising FileNotFoundError before any data was yielded), with a mocked stream that yields a chunk and then raises. This actually exercises the partially-written-file cleanup path. - Add a test asserting the partial file is preserved when delete_on_failure=False. - Guard os.remove() in download_object_range's failure handler so an error removing the partial file doesn't mask the original download exception. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #2227 +/- ##
=======================================
Coverage 83.67% 83.67%
=======================================
Files 352 352
Lines 82487 82524 +37
Branches 8901 8907 +6
=======================================
+ Hits 69015 69048 +33
- Misses 10592 10595 +3
- Partials 2880 2881 +1
🚀 New features to boost your workflow:
|
Changes Title (replace this with a logical title for your changes)
Description
Replace this with the PR description (mention the changes you have made, why
you have made them, provide some background and any references to the provider
documentation if needed, etc.).
For more information on contributing, please see Contributing
section of our documentation.
Status
Replace this: describe the PR status. Examples:
Checklist (tick everything that applies)