Skip to content

Close download responses when opening the destination fails - #609

Open
Shubham-Padkonde wants to merge 1 commit into
dropbox:mainfrom
Shubham-Padkonde:fix/close-failed-download-response
Open

Shubham-Padkonde wants to merge 1 commit into
dropbox:mainfrom
Shubham-Padkonde:fix/close-failed-download-response

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

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.

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.

1 participant