Skip to content

Commit

Permalink
Do not assert on diff if hard link sources are not found due to exclu…
Browse files Browse the repository at this point in the history
…sions.
  • Loading branch information
cr1901 committed Aug 26, 2024
1 parent 81cb1cd commit 30f861a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/borg/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def chunk_decref(id, stats, part=False):
logger.warning('borg check --repair is required to free all space.')

@staticmethod
def compare_archives_iter(archive1, archive2, matcher=None, can_compare_chunk_ids=False, content_only=False):
def compare_archives_iter(print_warning, archive1, archive2, matcher=None, can_compare_chunk_ids=False, content_only=False):
"""
Yields tuples with a path and an ItemDiff instance describing changes/indicating equality.
Expand Down Expand Up @@ -1117,10 +1117,16 @@ def defer_if_necessary(item1, item2):
update_hardlink_masters(deleted, deleted_item)
yield (path, compare_items(deleted, deleted_item))
for item1, item2 in deferred:
assert hardlink_master_seen(item1)
assert hardlink_master_seen(item2)
assert item1.path == item2.path, "Deferred items have different paths"
yield (item1.path, compare_items(item1, item2))
hl_notfound1 = not hardlink_master_seen(item1)
hl_notfound2 = not hardlink_master_seen(item2)
if hl_notfound1 or hl_notfound2:
if hl_notfound1:
print_warning(f"cannot find hardlink source for {item1.path} ({item1.source}), skipping compare.")
if hl_notfound2:
print_warning(f"cannot find hardlink source for {item2.path} ({item2.source}), skipping compare.")
else:
yield (item1.path, compare_items(item1, item2))


class MetadataCollector:
Expand Down
2 changes: 1 addition & 1 deletion src/borg/archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,7 @@ def print_text_output(diff, path):

matcher = self.build_matcher(args.patterns, args.paths)

diffs = Archive.compare_archives_iter(archive1, archive2, matcher, can_compare_chunk_ids=can_compare_chunk_ids, content_only=args.content_only)
diffs = Archive.compare_archives_iter(self.print_warning, archive1, archive2, matcher, can_compare_chunk_ids=can_compare_chunk_ids, content_only=args.content_only)
# Conversion to string and filtering for diff.equal to save memory if sorting
diffs = ((path, diff.changes()) for path, diff in diffs if not diff.equal)

Expand Down

0 comments on commit 30f861a

Please sign in to comment.