Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in SquashFSArchive._add #248 #306

Merged
merged 2 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions conda_pack/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,12 @@ def _add(self, source, target):
self._ensure_parent(target_abspath)

# hardlink instead of copy is faster, but it doesn't work across devices
same_device = os.lstat(source).st_dev == os.lstat(os.path.dirname(target_abspath)).st_dev
if same_device:
source_stat = os.lstat(source)
target_stat = os.lstat(os.path.dirname(target_abspath))
same_device = source_stat.st_dev == target_stat.st_dev
same_user = source_stat.st_uid == target_stat.st_uid

if same_device and same_user:
copy_func = partial(os.link, follow_symlinks=False)
else:
copy_func = partial(shutil.copy2, follow_symlinks=False)
Expand Down
20 changes: 20 additions & 0 deletions news/306-fix-hard-link-failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* In `SquashFSArchive._add` use copy instead of hard-link when source and
destination do not share file ownership (#248).

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>