Skip to content

Close download responses when opening the destination fails - #609

Merged
AndreyVMarkelov merged 2 commits into
dropbox:mainfrom
Shubham-Padkonde:fix/close-failed-download-response
Oct 7, 2026
Merged

AndreyVMarkelov merged 2 commits into
dropbox:mainfrom
Shubham-Padkonde:fix/close-failed-download-response

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

If the destination file cannot be opened (for example, its parent directory is missing), _save_body_to_file raises before entering the HTTP response's closing context. The unconsumed download response remains open.

Enter the response cleanup context before opening the local file so that file-open failures also release the response. Tests use a real Requests response backed by an urllib3 HTTPResponse and cover both a successful save and a missing destination directory.

Validation: the missing-directory case leaks the stream before the fix; all 102 unit tests pass afterward. Ruff lint and formatting pass.

@ineil-dbx

Copy link
Copy Markdown

Hi @Shubham-Padkonde, I’ve raised this with our engineering team for further review. They’ll be able to review the pull request and address it as appropriate.

@AndreyVMarkelov
AndreyVMarkelov self-requested a review October 7, 2026 17:24
@AndreyVMarkelov
AndreyVMarkelov merged commit 8888f74 into dropbox:main Oct 7, 2026
22 checks passed
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.

3 participants