From f515160bb075a52776a044504ab4bfc101ba4371 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 7 Nov 2024 21:12:51 +0100 Subject: [PATCH] mount: fix check_pending_archive to give correct root dir, fixes #8528 for archive series (duplicate names!), it is not just the archive name, but NAME-ARCHIVEID. --- src/borg/fuse.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/borg/fuse.py b/src/borg/fuse.py index 9636c932ed..a15d4714e6 100644 --- a/src/borg/fuse.py +++ b/src/borg/fuse.py @@ -273,6 +273,7 @@ def __init__(self, manifest, args, decrypted_repository): self.uid_forced = None self.gid_forced = None self.umask = 0 + self.archive_root_dir = {} # archive ID --> directory name def _create_filesystem(self): self._create_dir(parent=1) # first call, create root dir (inode == 1) @@ -280,6 +281,11 @@ def _create_filesystem(self): archives = self._manifest.archives.list_considering(self._args) name_counter = Counter(a.name for a in archives) duplicate_names = {a.name for a in archives if name_counter[a.name] > 1} + for archive in archives: + name = f"{archive.name}" + if name in duplicate_names: + name += f"-{bin_to_hex(archive.id):.8}" + self.archive_root_dir[archive.id] = name for archive in archives: if self.versions: # process archives immediately @@ -287,9 +293,7 @@ def _create_filesystem(self): else: # lazily load archives, create archive placeholder inode archive_inode = self._create_dir(parent=1, mtime=int(archive.ts.timestamp() * 1e9)) - name = f"{archive.name}" - if name in duplicate_names: - name += f"-{bin_to_hex(archive.id):.8}" + name = self.archive_root_dir[archive.id] self.contents[1][os.fsencode(name)] = archive_inode self.pending_archives[archive_inode] = archive @@ -310,7 +314,7 @@ def check_pending_archive(self, inode): # Check if this is an archive we need to load archive_info = self.pending_archives.pop(inode, None) if archive_info is not None: - self._process_archive(archive_info.id, [os.fsencode(archive_info.name)]) + self._process_archive(archive_info.id, [os.fsencode(self.archive_root_dir[archive_info.id])]) def _allocate_inode(self): self.inode_count += 1