Bläddra i källkod

borg mount --first / --last / --sort / --prefix, fixes #1542

also: use consider_part_files when dealing with multiple archives / whole repo mount
Thomas Waldmann 8 år sedan
förälder
incheckning
26e6ac4fea
2 ändrade filer med 13 tillägg och 12 borttagningar
  1. 2 6
      src/borg/archiver.py
  2. 11 6
      src/borg/fuse.py

+ 2 - 6
src/borg/archiver.py

@@ -853,12 +853,7 @@ class Archiver:
             return self.exit_code
             return self.exit_code
 
 
         with cache_if_remote(repository) as cached_repo:
         with cache_if_remote(repository) as cached_repo:
-            if args.location.archive:
-                archive = Archive(repository, key, manifest, args.location.archive,
-                                  consider_part_files=args.consider_part_files)
-            else:
-                archive = None
-            operations = FuseOperations(key, repository, manifest, archive, cached_repo)
+            operations = FuseOperations(key, repository, manifest, args, cached_repo, archiver=self)
             logger.info("Mounting filesystem")
             logger.info("Mounting filesystem")
             try:
             try:
                 operations.mount(args.mountpoint, args.options, args.foreground)
                 operations.mount(args.mountpoint, args.options, args.foreground)
@@ -2115,6 +2110,7 @@ class Archiver:
                                help='stay in foreground, do not daemonize')
                                help='stay in foreground, do not daemonize')
         subparser.add_argument('-o', dest='options', type=str,
         subparser.add_argument('-o', dest='options', type=str,
                                help='Extra mount options')
                                help='Extra mount options')
+        self.add_archives_filters_args(subparser)
 
 
         info_epilog = textwrap.dedent("""
         info_epilog = textwrap.dedent("""
         This command displays detailed information about the specified archive or repository.
         This command displays detailed information about the specified archive or repository.

+ 11 - 6
src/borg/fuse.py

@@ -58,11 +58,12 @@ class FuseOperations(llfuse.Operations):
     allow_damaged_files = False
     allow_damaged_files = False
     versions = False
     versions = False
 
 
-    def __init__(self, key, repository, manifest, archive, cached_repo):
+    def __init__(self, key, repository, manifest, args, cached_repo, archiver):
         super().__init__()
         super().__init__()
+        self.archiver = archiver
         self.repository_uncached = repository
         self.repository_uncached = repository
         self.repository = cached_repo
         self.repository = cached_repo
-        self.archive = archive
+        self.args = args
         self.manifest = manifest
         self.manifest = manifest
         self.key = key
         self.key = key
         self._inode_count = 0
         self._inode_count = 0
@@ -79,11 +80,15 @@ class FuseOperations(llfuse.Operations):
 
 
     def _create_filesystem(self):
     def _create_filesystem(self):
         self._create_dir(parent=1)  # first call, create root dir (inode == 1)
         self._create_dir(parent=1)  # first call, create root dir (inode == 1)
-        if self.archive:
-            self.process_archive(self.archive)
+        if self.args.location.archive:
+            archive = Archive(self.repository_uncached, self.key, self.manifest, self.args.location.archive,
+                              consider_part_files=self.args.consider_part_files)
+            self.process_archive(archive)
         else:
         else:
-            for name in self.manifest.archives:
-                archive = Archive(self.repository_uncached, self.key, self.manifest, name)
+            archive_names = (x.name for x in self.archiver._get_filtered_archives(self.args, self.manifest))
+            for name in archive_names:
+                archive = Archive(self.repository_uncached, self.key, self.manifest, name,
+                                  consider_part_files=self.args.consider_part_files)
                 if self.versions:
                 if self.versions:
                     # process archives immediately
                     # process archives immediately
                     self.process_archive(archive)
                     self.process_archive(archive)