import-tar: fix nfiles being counted twice for regular files - #10146
Merged
ThomasWaldmann merged 1 commit intoAug 18, 2026
Merged
Conversation
_import_tar incremented archive.stats.nfiles for every regular tar member, but TarfileObjectProcessors.process_file already counts those in tfo.stats (and process_hardlink counts hardlink members). Since archive.stats += tfo.stats is added before archive.save(), imported archives persisted nfiles = 2 * regular_files + hardlinks. Remove the redundant increment (borg create also relies solely on the processor-side accounting) and add a test asserting that the archive metadata nfiles equals regular files + hardlink members after borg import-tar. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ThomasWaldmann
force-pushed
the
claude/charming-bohr-fd92ea
branch
from
August 18, 2026 14:31
8d77d13 to
30194fb
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10146 +/- ##
=======================================
Coverage 86.94% 86.95%
=======================================
Files 101 101
Lines 17984 17983 -1
Branches 2737 2737
=======================================
Hits 15637 15637
- Misses 1638 1639 +1
+ Partials 709 707 -2 ☔ View full report in Codecov by Harness. |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin 1.4-maint
git worktree add -d .worktree/backport-10146-to-1.4-maint origin/1.4-maint
cd .worktree/backport-10146-to-1.4-maint
git switch --create backport-10146-to-1.4-maint
git cherry-pick -x 30194fb64f747c0b78900149687d78c213f08b8c |
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.
Summary
_import_tarincrementedarchive.stats.nfilesfor every regular tar member, butTarfileObjectProcessors.process_filealready counts those intfo.stats(andprocess_hardlinkcounts hardlink members). Sincearchive.stats += tfo.statsis added beforearchive.save(), imported archives persistednfiles = 2 * regular_files + hardlinksinto the archive metadata, soborg info/borg repo-listreported a wrong file count for imported archives.Remove the redundant increment —
borg createalso relies solely on the processor-side accounting, soimport-tarnow matches its semantics (each regular file and each hardlink counts once; directories/symlinks/devices/fifos do not).Test
Added
test_import_tar_nfiles: builds a tar via Python'starfilemodule (no GNU tar or filesystem hardlink support needed) containing 2 regular files, 1 hardlink member, 1 directory and 1 symlink, imports it, and asserts the archive metadata reportsnfiles == 3. Verified the test fails withassert 5 == 3on the unfixed code.🤖 Generated with Claude Code