create/import-tar --json: report the deduplicated size of the new archive, #10335 - #10336
Merged
ThomasWaldmann merged 1 commit intoSep 7, 2026
Merged
Conversation
…hive, borgbackup#10335 Statistics.usize (the size of the chunks that were new to the repository) is accumulated while an archive is created and printed as "Deduplicated size" in the text --stats block, but Statistics.as_dict() did not include it, so the --json output (which replaces the text block) had no way to get it. as_dict() now reports it as "deduplicated_size", as borg 1.x did (there it was the deduplicated compressed size, in borg 2 it is the deduplicated original size, see the 2.0.0a2 changelog). This covers borg create --json, borg import-tar --json and the archive_progress JSON lines. Archive.calc_stats() (used by borg info) can not compute the deduplicated size of an existing archive (that is expensive, see borg analyze), so it now marks usize as unknown (None) and as_dict() leaves the key out there instead of reporting a misleading 0. Also fix the create help text: borg 2 prints a single stats block, there is no "This Archive" / "All archives" table anymore. 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 #10336 +/- ##
==========================================
+ Coverage 87.74% 87.75% +0.01%
==========================================
Files 103 103
Lines 18817 18821 +4
Branches 2905 2906 +1
==========================================
+ Hits 16511 16517 +6
+ Misses 1602 1600 -2
Partials 704 704 ☔ View full report in Codecov by Harness. |
Merged
17 tasks
|
Great. Thanks |
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.
Fixes #10335.
The claim in the issue is correct:
Statistics.usizeis accumulated while creating an archive and printed asDeduplicated size:in the text--statsblock, butStatistics.as_dict()did not include it, and--jsonreplaces the text block, so a JSON consumer could not get the deduplicated size at all.borg infocan not recover it later (calc_stats()does not compute it, that is expensive).Changes
Statistics.as_dict()reportsdeduplicated_size(the borg 1.x key; in borg 2 it is the deduplicated original size, see the 2.0.0a2 changelog). This coversborg create --json,borg import-tar --jsonand thearchive_progressJSON lines (which already show theUsize in text mode).Archive.calc_stats()(used byborg info) marksusizeas unknown (None) instead of0, andas_dict()leaves the key out then. Soinfo --jsonstays honest: absent means "not computed", not "zero" (option 2 from the issue).docs/internals/frontends.rst(keys, examples, the borg info note),docs/changes.rst, and thecreate/infohelp texts (docs/usage/*.rst.incregenerated, only these two files changed). Thecreatehelp still described a borg 1.x "This Archive" / "All archives" table that borg 2 does not print; fixed while there.Statistics.as_dict()unit test,create --json(fresh repo vs. repeated backup),import-tar --json, andinfo --jsonnot having the key.Sample output (borg from this branch)
The
--dry-run --jsonoutput is unchanged (nfilesandoriginal_sizeonly, nothing is deduplicated there).🤖 Generated with Claude Code