diff --git a/conda_pack/formats.py b/conda_pack/formats.py index 806d725..91a5653 100644 --- a/conda_pack/formats.py +++ b/conda_pack/formats.py @@ -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) diff --git a/news/306-fix-hard-link-failure b/news/306-fix-hard-link-failure new file mode 100644 index 0000000..7a121fb --- /dev/null +++ b/news/306-fix-hard-link-failure @@ -0,0 +1,20 @@ +### Enhancements + +* + +### Bug fixes + +* In `SquashFSArchive._add` use copy instead of hard-link when source and +destination do not share file ownership (#248). + +### Deprecations + +* + +### Docs + +* + +### Other + +*