From 6ef5c9c960e99125c4e58c2ec76f9ff2cce2d65e Mon Sep 17 00:00:00 2001 From: Milkey Mouse Date: Sun, 16 Jul 2017 18:23:11 -0700 Subject: [PATCH] Use archive creation time as mtime for FUSE mount (fixes #2834) --- src/borg/fuse.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/borg/fuse.py b/src/borg/fuse.py index 344247c21..7868eb378 100644 --- a/src/borg/fuse.py +++ b/src/borg/fuse.py @@ -242,16 +242,15 @@ def _create_filesystem(self): self.process_archive(self.args.location.archive) else: self.versions_index = FuseVersionsIndex() - archive_names = (x.name for x in self.manifest.archives.list_considering(self.args)) - for archive_name in archive_names: + for archive in self.manifest.archives.list_considering(self.args): if self.versions: # process archives immediately - self.process_archive(archive_name) + self.process_archive(archive.name) else: # lazily load archives, create archive placeholder inode - archive_inode = self._create_dir(parent=1) - self.contents[1][os.fsencode(archive_name)] = archive_inode - self.pending_archives[archive_inode] = archive_name + archive_inode = self._create_dir(parent=1, mtime=int(archive.ts.timestamp() * 1e9)) + self.contents[1][os.fsencode(archive.name)] = archive_inode + self.pending_archives[archive_inode] = archive.name def sig_info_handler(self, sig_no, stack): logger.debug('fuse: %d synth inodes, %d edges (%s)', @@ -303,11 +302,15 @@ def mount(self, mountpoint, mount_options, foreground=False): finally: llfuse.close(umount) - def _create_dir(self, parent): + def _create_dir(self, parent, mtime=None): """Create directory """ ino = self.allocate_inode() - self.items[ino] = self.default_dir + if mtime is not None: + self.items[ino] = Item(**self.default_dir.as_dict()) + self.items[ino].mtime = mtime + else: + self.items[ino] = self.default_dir self.parent[ino] = parent return ino @@ -375,7 +378,7 @@ def make_versioned_name(name, version, add_dir=False): self.file_versions[path] = version path = item.path - del item.path # safe some space + del item.path # save some space if 'source' in item and hardlinkable(item.mode): # a hardlink, no contents, is the hardlink master source = os.fsencode(item.source)