zhechen-cs opened a new issue, #2200:
URL: https://github.com/apache/libcloud/issues/2200

   ## Summary
   
   `LocalStorageDriver.download_object()` deletes the stored object when the 
destination resolves to the source file and `overwrite_existing=True` is used. 
The default failure cleanup unlinks the source after `shutil.copy()` raises 
`SameFileError`.
   
   ## Reproducer
   
   On current `trunk` (`bd9cbb3e393bc42f57684481e7c62e9293007584`), Python 3.12:
   
   ```python
   import os
   import tempfile
   from libcloud.storage.drivers.local import LocalStorageDriver
   
   with tempfile.TemporaryDirectory() as root:
       driver = LocalStorageDriver(root)
       container = driver.create_container("bucket")
       obj = driver.upload_object_via_stream(iter([b"payload"]), container, 
"object")
       path = os.path.join(root, "bucket", "object")
       print(driver.download_object(obj, path, overwrite_existing=True))  # 
False
       print(os.path.exists(path))  # False: the stored object was deleted
   ```
   
   The failed download should preserve the source. The same deletion occurs 
when the destination is the containing directory with a trailing path separator.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to