Merge pull request #9501 from ebuzerdrmz44/fix/transfer-cwd-metadata
Some checks are pending
Lint / lint (push) Waiting to run
CI / lint (push) Waiting to run
CI / security (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OmniOS, false, omnios, r151056) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.8) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CI / windows_tests (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run

Fixes #9495 preserve cwd archive metadata
This commit is contained in:
TW 2026-03-19 10:42:45 +01:00 committed by GitHub
commit 742978911c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 0 deletions

View file

@ -711,6 +711,8 @@ Duration: {0.duration}
stats = stats or self.stats
metadata |= {"size": stats.osize, "nfiles": stats.nfiles}
metadata |= additional_metadata or {}
if metadata.get("cwd") is None:
del metadata["cwd"]
metadata = ArchiveItem(metadata)
data = self.key.pack_metadata(metadata.as_dict())
self.id = self.repo_objs.id_hash(data)

View file

@ -363,6 +363,7 @@ def test_transfer_archive_metadata(archivers, request, monkeypatch):
assert dest_archive["hostname"] == source_archive["hostname"]
assert dest_archive["username"] == source_archive["username"]
assert dest_archive["command_line"] == source_archive["command_line"]
assert dest_archive["cwd"] == source_archive["cwd"]
assert dest_archive["duration"] == source_archive["duration"]
assert dest_archive["start"] == source_archive["start"]
assert dest_archive["end"] == source_archive["end"]

View file

@ -39,6 +39,7 @@ class UpgraderNoOp:
):
if hasattr(metadata, attr):
new_metadata[attr] = getattr(metadata, attr)
new_metadata["cwd"] = getattr(metadata, "cwd", None) # None signals save() to leave cwd unset
rechunking = self.args.chunker_params is not None
if rechunking:
# if we are rechunking while transferring, we take the new chunker_params.
@ -152,6 +153,8 @@ class UpgraderFrom12To20:
for attr in ("hostname", "username", "comment", "chunker_params"):
if hasattr(metadata, attr):
new_metadata[attr] = getattr(metadata, attr)
# if cwd is None, we want to drop it from metadata, so we set it to None here, and save() will drop it.
new_metadata["cwd"] = getattr(metadata, "cwd", None)
rechunking = self.args.chunker_params is not None
if rechunking:
# if we are rechunking while transferring, we take the new chunker_params.