Blob.download_to_filename leaves empty file if not found #1342
Labels
api: storage
Issues related to the googleapis/python-storage API.
status: investigating
The issue is under investigation, which is determined to be non-trivial.
Environment details
python --version
3.11.3pip --version
24.2google-cloud-storage
version:pip show google-cloud-storage
2.14.0Steps to reproduce
Use
Blob.download_to_filename
with a key that doesn't exist. This leaves an empty file. I expected the file to be cleaned up if any problem occurs during the download.Code example
Stack trace
Looking at
Blob.download_to_filename
(and in turn atBlob._handle_filename_and_download
) it is pretty obvious where this behavior originates:The file is only cleaned up for that specific exception, and not any other.
The text was updated successfully, but these errors were encountered: