mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
mount: do pre-mount checks before opening repository
This commit is contained in:
parent
334a7007da
commit
869ab1a47b
1 changed files with 6 additions and 4 deletions
|
@ -1231,22 +1231,24 @@ def _delete_repository(self, args, repository):
|
||||||
|
|
||||||
def do_mount(self, args):
|
def do_mount(self, args):
|
||||||
"""Mount archive or an entire repository as a FUSE filesystem"""
|
"""Mount archive or an entire repository as a FUSE filesystem"""
|
||||||
|
# Perform these checks before opening the repository and asking for a passphrase.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import borg.fuse
|
import borg.fuse
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
self.print_error('borg mount not available: loading fuse support failed [ImportError: %s]' % str(e))
|
self.print_error('borg mount not available: loading fuse support failed [ImportError: %s]' % str(e))
|
||||||
return self.exit_code
|
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)
|
return self._do_mount(args)
|
||||||
|
|
||||||
@with_repository()
|
@with_repository()
|
||||||
def _do_mount(self, args, repository, manifest, key):
|
def _do_mount(self, args, repository, manifest, key):
|
||||||
from .fuse import FuseOperations
|
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:
|
with cache_if_remote(repository) as cached_repo:
|
||||||
operations = FuseOperations(key, repository, manifest, args, cached_repo)
|
operations = FuseOperations(key, repository, manifest, args, cached_repo)
|
||||||
logger.info("Mounting filesystem")
|
logger.info("Mounting filesystem")
|
||||||
|
|
Loading…
Reference in a new issue