From 26e6ac4fea2c1f913cc0998fd8592ce0abe8095a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 13 Oct 2016 03:08:57 +0200 Subject: [PATCH] borg mount --first / --last / --sort / --prefix, fixes #1542 also: use consider_part_files when dealing with multiple archives / whole repo mount --- src/borg/archiver.py | 8 ++------ src/borg/fuse.py | 17 +++++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 11ace7056..736f725b8 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -853,12 +853,7 @@ def do_mount(self, args, repository, manifest, key): return self.exit_code 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") try: operations.mount(args.mountpoint, args.options, args.foreground) @@ -2115,6 +2110,7 @@ def build_parser(self, prog=None): help='stay in foreground, do not daemonize') subparser.add_argument('-o', dest='options', type=str, help='Extra mount options') + self.add_archives_filters_args(subparser) info_epilog = textwrap.dedent(""" This command displays detailed information about the specified archive or repository. diff --git a/src/borg/fuse.py b/src/borg/fuse.py index b822332dd..02b41b55e 100644 --- a/src/borg/fuse.py +++ b/src/borg/fuse.py @@ -58,11 +58,12 @@ class FuseOperations(llfuse.Operations): allow_damaged_files = False versions = False - def __init__(self, key, repository, manifest, archive, cached_repo): + def __init__(self, key, repository, manifest, args, cached_repo, archiver): super().__init__() + self.archiver = archiver self.repository_uncached = repository self.repository = cached_repo - self.archive = archive + self.args = args self.manifest = manifest self.key = key self._inode_count = 0 @@ -79,11 +80,15 @@ def __init__(self, key, repository, manifest, archive, cached_repo): def _create_filesystem(self): 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: - 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: # process archives immediately self.process_archive(archive)