Repository: borgbackup/borg

Issue:
Modification time in fuse mount should show creation time of archive
STR: (tested with 1.1.0b6)
``` 
# create some backups
borg mount :: /tmp/mount
ls -la /tmp/mount
total 0
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 .
drwxrwxrwt. 27 root root 660 Jul 16 18:58 ..
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 backup-block-device
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 backup1
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 backup2
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 backup3
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 rugk-2017-07-16T18:51:34
drwxr-xr-x.  1 rugk rugk   0 Jul 16 18:58 rugk-2017-07-16T18:52:19
```

They are all set to the current time. It would be better if the directories show the creation time of the archives as their "modification time".


Discussion:

Resolving patch:
diff --git a/src/borg/fuse.py b/src/borg/fuse.py
--- 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, <source> is the hardlink master
             source = os.fsencode(item.source)


Test patch: