소스 검색

mount: do pre-mount checks before opening repository

Marian Beermann 8 년 전
부모
커밋
fa9cef7abf
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      borg/archiver.py

+ 6 - 4
borg/archiver.py

@@ -559,22 +559,24 @@ class Archiver:
 
     def do_mount(self, args):
         """Mount archive or an entire repository as a FUSE filesystem"""
+        # Perform these checks before opening the repository and asking for a passphrase.
+
         try:
             import borg.fuse
         except ImportError as e:
             self.print_error('borg mount not available: loading fuse support failed [ImportError: %s]' % str(e))
             return self.exit_code
 
+        if not os.path.isdir(args.mountpoint) or not os.access(args.mountpoint, os.R_OK | os.W_OK | os.X_OK):
+            self.print_error('%s: Mountpoint must be a writable directory' % args.mountpoint)
+            return self.exit_code
+
         return self._do_mount(args)
 
     @with_repository()
     def _do_mount(self, args, repository, manifest, key):
         from .fuse import FuseOperations
 
-        if not os.path.isdir(args.mountpoint) or not os.access(args.mountpoint, os.R_OK | os.W_OK | os.X_OK):
-            self.print_error('%s: Mountpoint must be a writable directory' % args.mountpoint)
-            return self.exit_code
-
         with cache_if_remote(repository) as cached_repo:
             if args.location.archive:
                 archive = Archive(repository, key, manifest, args.location.archive)