extract --continue: keep groups of hard links together - #10387
Merged
ThomasWaldmann merged 1 commit intoSep 19, 2026
Merged
Conversation
When --continue skipped an already extracted file that is part of a group of hard links, the hard link manager did not learn its path. A following item of the same group was then extracted as a separate file instead of being hard linked to the skipped one. Now a skipped first item of a group is remembered as the link target, and a skipped later item is only left alone if it already is a hard link to the group's link target. Otherwise it is replaced by a hard link to it (this happens if the first item of the group had to be extracted again). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10387 +/- ##
==========================================
- Coverage 88.19% 88.15% -0.05%
==========================================
Files 103 103
Lines 18822 18829 +7
Branches 2919 2922 +3
==========================================
- Hits 16600 16598 -2
- Misses 1548 1555 +7
- Partials 674 676 +2 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
borg extract --continuecould break up a group of hard links.The bug
When
--continuefinds that a file already is fully extracted (same type/mode, size and mtime),extract_item()returned right away - before the hard link manager learned the path of that file. If that file was the first item of a group of hard links, a following item of the same group found no link target and was extracted as a separate file (own inode, own copy of the content).Reproduction: archive
a,b,c(hard links of each other), extract,rm c(simulating an extraction that was interrupted beforec),borg extract --continue:The fix
On the "already extracted" path of
--continue, for items that are part of a group of hard links:os.path.samestat). Otherwise it is replaced by a hard link to it. This covers the opposite order: the first item of the group is missing and had to be extracted again, while another link of the group still exists - without this, the existing one would stay on the old inode.Items without
hlidand platforms withoutos.linkbehave as before.Tests
test_extract_continue_hardlinksremoves either the first or the last item of a group of 3 hard links (the order within the archive depends on the filesystem, so the test asksborg listfor it) and checks that afterextract --continueall 3 are hard links to one inode again, and that already extracted files are not extracted again. Both variants fail without the fix.Found while working on #10057, where
--continueis planned to become the way to extract into a non-empty directory.🤖 Generated with Claude Code