Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress modified changes for files which weren't actually modified in JSON output. #8334

Merged
merged 3 commits into from
Aug 21, 2024

Conversation

cr1901
Copy link

@cr1901 cr1901 commented Aug 16, 2024

Right now, if borg diff is run with the --json-lines parameter (and without --content-only, files whose content have not been modified will still be given a modified entry of {"added": 0, "removed": 0, "type": "modified"}, e.g.:

 {"changes": [{"added": 0, "removed": 0, "type": "modified"}, {"new_ctime": "2024-07-22T20:13:59.352959", "old_ctime": "2020-01-06T02:21:13.955255", "type": "ctime"}], "path": ".areca/workspace/.log/areca.12-06-24.log"}

Per IRC discussion, this is considered a bug, as the file's content was not actually changed, and thus shouldn't be in the changes JSON array. This PR fixes the behavior so that JSON entries no longer get a "type": "modified" object for files whose contents weren't changed, but ctime, mtime, etc were changed. E.g.:

{"changes": [{"new_ctime": "2024-07-22T20:13:59.352959", "old_ctime": "2020-01-06T02:21:13.955255", "type": "ctime"}], "path": ".areca/workspace/.log/areca.12-06-24.log"}

Text output (without --json-lines) is unaffected; I feel that the 0 B 0 B is more useful for humans looking at output, compared to JSON processors :):

      0 B       0 B [ctime: Mon, 2020-01-06 02:21:13 -> Mon, 2024-07-22 20:13:59] .areca/workspace/.log/areca.12-06-24.log

@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.73%. Comparing base (adf2d8c) to head (938e144).
Report is 7 commits behind head on 1.4-maint.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@              Coverage Diff              @@
##           1.4-maint    #8334      +/-   ##
=============================================
+ Coverage      82.69%   82.73%   +0.03%     
=============================================
  Files             38       38              
  Lines          11045    11049       +4     
  Branches        2122     2123       +1     
=============================================
+ Hits            9134     9141       +7     
+ Misses          1345     1344       -1     
+ Partials         566      564       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/archiver.py Outdated Show resolved Hide resolved
src/borg/testsuite/archiver.py Show resolved Hide resolved
src/borg/testsuite/archiver.py Show resolved Hide resolved
@ThomasWaldmann
Copy link
Member

@cr1901 OK, guess this is ready to merge?

@cr1901
Copy link
Author

cr1901 commented Aug 20, 2024

@ThomasWaldmann Okay to merge.

@ThomasWaldmann ThomasWaldmann merged commit 0ebb80c into borgbackup:1.4-maint Aug 21, 2024
9 checks passed
@ThomasWaldmann
Copy link
Member

@cr1901 Thanks!

@ThomasWaldmann
Copy link
Member

Guess a forward port to master branch would be good.

1.2-maint will be phased out in a while, so a backport to there is optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants