Fixes #9495 preserve cwd archive metadata#9501
Fixes #9495 preserve cwd archive metadata#9501ThomasWaldmann merged 3 commits intoborgbackup:masterfrom
Conversation
| for attr in ("hostname", "username", "comment", "chunker_params"): | ||
| for attr in ("hostname", "username", "comment", "chunker_params", "cwd"): | ||
| if hasattr(metadata, attr): | ||
| new_metadata[attr] = getattr(metadata, attr) |
There was a problem hiding this comment.
ok, guess that solves it for borg 1.4 archives that do have the cwd metadata (borg 1.4.4+).
but what happens if an older archive gets transferred that does not have the cwd metadata, what will be and what should be in the resulting archive?
There was a problem hiding this comment.
thanks for the review. I guess we shouldn't check cwd inside the for loop. After the loop, could we check it specifically, like getattr(metadata, "cwd", "")?
There was a problem hiding this comment.
But I'm not sure if "" is the best choice here . would you prefer leaving cwd unset or is that fine
There was a problem hiding this comment.
if we can't know, having it unset might be the best choice. check if the code can cope with that.
There was a problem hiding this comment.
Turns out omitting cwd from additional_metadata wasn't enough . save() always falls back to self.cwd. Used None as a sentinel instead: upgraders pass cwd=None for archives without it, and save() drops the key when it sees None.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9501 +/- ##
==========================================
+ Coverage 83.36% 83.37% +0.01%
==========================================
Files 87 87
Lines 15439 15448 +9
Branches 2309 2311 +2
==========================================
+ Hits 12870 12880 +10
Misses 1818 1818
+ Partials 751 750 -1 ☔ View full report in Codecov by Sentry. |
|
Thanks! |
Description
borg transferwas not preserving thecwdarchive metadata from the source archive. Instead, the transferred archive would end up with the cwd of the machine running the transfer command.This adds
cwdto the kept attributes in bothUpgraderNoOpandUpgraderFrom12To20, so the original value is carried over. Also added a check for ittest_transfer_archive_metadata.Fixes #9495
Checklist
master(or maintenance branch if only applicable there)toxor the relevant test subset)