Skip to content

Commit

Permalink
fix transfer/upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed Nov 25, 2024
1 parent fa70d2f commit 960b601
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/borg/archiver/transfer_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def do_transfer(self, args, *, repository, manifest, cache, other_repository=Non
chunks.append(chunk_entry)
present_size += size
if not dry_run:
item.chunks = chunks # TODO: overwrite? IDs and sizes are same.
item.chunks = chunks
archive.stats.nfiles += 1
if not dry_run:
item = upgrader.upgrade_item(item=item)
Expand Down
15 changes: 2 additions & 13 deletions src/borg/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def upgrade_item(self, *, item):
ITEM_KEY_WHITELIST = {
"path",
"rdev",
"chunks",
"hlid",
"mode",
"user",
Expand All @@ -76,13 +77,7 @@ def upgrade_item(self, *, item):

if self.hlm.borg1_hardlink_master(item):
item.hlid = hlid = self.hlm.hardlink_id_from_path(item.path)
if "chunks_healthy" in item:
chunks_correct = item.chunks_healthy
elif "chunks" in item:
chunks_correct = item.chunks
else:
chunks_correct = None
self.hlm.remember(id=hlid, info=chunks_correct)
self.hlm.remember(id=hlid, info=item.get("chunks"))
elif self.hlm.borg1_hardlink_slave(item):
item.hlid = hlid = self.hlm.hardlink_id_from_path(item.source)
chunks = self.hlm.retrieve(id=hlid)
Expand All @@ -96,12 +91,6 @@ def upgrade_item(self, *, item):
# - 'hardlink_master' (superseded by hlid)
item_dict = item.as_dict()
new_item_dict = {key: value for key, value in item_dict.items() if key in ITEM_KEY_WHITELIST}
if "chunks_healthy" in item_dict:
# we want the chunks list with the CORRECT chunk ids, even if the chunk is missing.
new_item_dict["chunks"] = item_dict["chunks_healthy"]
elif "chunks" in item_dict:
# if there is no .chunks_healthy, the correct chunk ids are in .chunks.
new_item_dict["chunks"] = item_dict["chunks"]
# symlink targets were .source for borg1, but borg2 uses .target:
if "source" in item_dict:
new_item_dict["target"] = item_dict["source"]
Expand Down

0 comments on commit 960b601

Please sign in to comment.