From e5f1a4fb4d74cc5cdc1cd38f14200f4db782a35a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 11 May 2022 23:52:04 +0200 Subject: [PATCH] recreate: cachedir_masters not needed any more now all hardlinked regular file items have chunks. --- src/borg/archive.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index da083eac6..ed17465ea 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -2199,30 +2199,13 @@ class ArchiveRecreater: tag_files = [] tagged_dirs = [] - # to support reading hard-linked CACHEDIR.TAGs (aka CACHE_TAG_NAME): - cachedir_masters = {} - - if self.exclude_caches: - # sadly, due to how CACHEDIR.TAG works (filename AND file [header] contents) and - # how borg deals with hardlinks (slave hardlinks referring back to master hardlinks), - # we need to pass over the archive collecting hardlink master paths. - # as seen in issue #4911, the master paths can have an arbitrary filenames, - # not just CACHEDIR.TAG. - for item in archive.iter_items(filter=lambda item: os.path.basename(item.path) == CACHE_TAG_NAME): - if stat.S_ISREG(item.mode) and 'chunks' not in item and 'source' in item: - # this is a hardlink slave, referring back to its hardlink master (via item.source) - cachedir_masters[item.source] = None # we know the key (path), but not the value (item) yet - for item in archive.iter_items( filter=lambda item: os.path.basename(item.path) == CACHE_TAG_NAME or matcher.match(item.path)): - if self.exclude_caches and item.path in cachedir_masters: - cachedir_masters[item.path] = item dir, tag_file = os.path.split(item.path) if tag_file in self.exclude_if_present: exclude(dir, item) elif self.exclude_caches and tag_file == CACHE_TAG_NAME and stat.S_ISREG(item.mode): - content_item = item if 'chunks' in item else cachedir_masters[item.source] - file = open_item(archive, content_item) + file = open_item(archive, item) if file.read(len(CACHE_TAG_CONTENTS)) == CACHE_TAG_CONTENTS: exclude(dir, item) matcher.add(tag_files, IECommand.Include)