Skip to content

Preserve local objects when downloading onto the source - #2201

Merged
micafer merged 3 commits into
apache:trunkfrom
zhechen-cs:codex/local-download-same-file
Nov 7, 2026
Merged

micafer merged 3 commits into
apache:trunkfrom
zhechen-cs:codex/local-download-same-file

Conversation

@zhechen-cs

Copy link
Copy Markdown
Contributor

Description

Handle shutil.SameFileError before ordinary copy failures in the local storage driver. Downloading an object onto itself still returns False, but no longer deletes the source object during failure cleanup.

The regression checks both an explicit source filename and its containing directory with a trailing separator, then verifies the stored contents and object metadata remain available.

Fixes #2200

Status

Ready for review.

Validation

  • Local storage and base storage tests: 33 passed, 2 subtests passed (Python 3.12).
  • Both regression cases fail against unmodified trunk with FileNotFoundError after the source is deleted.
  • Black, isort, flake8, pylint and git diff --check pass for the changed files.
  • Live cloud integration tests were not run; this fix only affects the local storage driver.

Checklist

  • Code linting
  • Documentation (no public API change)
  • Tests
  • ICLA (small bug fix)

@micafer micafer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov-commenter

codecov-commenter commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.58%. Comparing base (5ec65f1) to head (01d93bf).

Files with missing lines Patch % Lines
libcloud/storage/drivers/local.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2201   +/-   ##
=======================================
  Coverage   83.58%   83.58%           
=======================================
  Files         352      352           
  Lines       82117    82131   +14     
  Branches     8808     8812    +4     
=======================================
+ Hits        68634    68649   +15     
+ Misses      10608    10607    -1     
  Partials     2875     2875           
Files with missing lines Coverage Δ
libcloud/test/storage/test_local.py 91.60% <100.00%> (+0.28%) ⬆️
libcloud/storage/drivers/local.py 76.40% <50.00%> (+0.59%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@micafer

micafer commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Please add an entry in the changelog.

@micafer
micafer merged commit 647d5a7 into apache:trunk Nov 7, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local storage downloads onto the source delete the stored object

3 participants