fix: prevent file deletion during self-linking in link_or_copy
Metadata
Current evaluation
PR #1628 merged (commit 98281de6): adds a samefile() guard in link_or_copy (craft_parts/utils/file_utils.py) so organize no longer unlinks/deletes the source file when a staged symlink self-links, fixing snapcraft#6168.
Resolution: closed resolved
Reason: The PR itself was merged into craft-parts as commit 98281de6 after two approving reviewers. The change is present in craft_parts/utils/file_utils.py: link_or_copy now returns early when source.exists() and destination.exists() and source.samefile(destination), preventing the EEXIST-handling unlink from deleting the source; it also fixes canonical/snapcraft#6168. Remaining CI failures were network/arch flakiness, not the change.
Evaluated by: mr-cal-bot
Issue body
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | PR #1628 merged (commit 98281de6): adds a samefile() guard in link_or_copy (craft_parts/utils/file_utils.py) so organize no longer unlinks/deletes the source file when a staged symlink self-links, fixing snapcraft#6168. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged as canonical/craft-parts#1628 (commit 98281de6), adding a samefile() guard so organize skips self-link collisions without deleting the source file. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged fix for link_or_copy preventing accidental source deletion during self-linking. Added a samefile check to safely skip identical paths, resolving #6168. Approved and merged after CI validation. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
5
Complexity:
15
Confidence:
90
|
needs review | Fixes a bug in link_or_copy that deleted source files during self-linking collisions by adding a samefile() check. PR has 2 approvals, 0 unresolved comments, and passing CI excluding flaky infra failures. Awaiting CI re-run. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
40
Complexity:
15
Confidence:
90
|
needs review | Fixes file deletion bug during self-linking collisions by adding a samefile() check. Approved by two reviewers, currently awaiting CI re-run for unrelated flaky failures. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
5
Complexity:
15
Confidence:
90
|
needs review | Fixes file deletion during self-linking collisions by adding a samefile() check in link_or_copy. Approved by one reviewer, awaiting CI re-run for unrelated flaky failures. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
15
Complexity:
15
Confidence:
90
|
needs review | Fixes a bug where link_or_copy deletes source files during self-linking collisions by adding a samefile() check. PR has 1 approval, 0 unresolved comments, and awaits CI workflow approval and maintainer review. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
10
Complexity:
15
Confidence:
85
|
needs review | Fixes a bug where self-linking collisions in link_or_copy caused unintended source file deletion. Adds a samefile() check to safely ignore collisions. Approved by one reviewer, awaiting CI approval and final merge. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
60
Complexity:
15
Confidence:
85
|
needs review | Adds a samefile() check to link_or_copy to prevent accidental source file deletion during self-linking collisions. Currently awaiting maintainer review and CI workflow approval. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
20
Complexity:
15
Confidence:
90
|
needs review | Fixes a file deletion bug in link_or_copy when handling self-linking symlinks by adding a samefile check. Awaiting maintainer review and CI approval. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
5
Complexity:
15
Confidence:
90
|
needs review | Fixes file deletion bug in link_or_copy when source and destination resolve to the same file via symlink. Adds samefile() check to prevent accidental unlinking. Currently awaiting maintainer review and CI approval. |
Update history
| Date | Change |
|---|---|
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated |
Related work
-
Related To:
canonical/snapcraft#6168
(confidence 90%)
Upstream snapcraft issue ('Can't "build-time resolve" staged symlinks with organize') cited as fixed by this PR.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1658155 file_utils.link_or_copy_tree doesn't maintain symlinks to directories | snapcraft (launchpad) | closed | Fixed directory-symlink handling in file_utils.link_or_copy_tree by merging snapcore/snapcraft PR #1063 in commit 7768cd33b. |