1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-24 15:12:00 +00:00

borg mount -a ARCHIVE_GLOB mountpoint ...

This commit is contained in:
Thomas Waldmann 2022-06-20 20:11:26 +02:00
parent e6a8984c99
commit 6addafd784
3 changed files with 27 additions and 36 deletions

View file

@ -3264,8 +3264,6 @@ def define_archive_filters_group(subparser, *, sort_by=True, first_last=True):
def define_borg_mount(parser):
parser.set_defaults(func=self.do_mount)
parser.add_argument('--name', dest='name', metavar='NAME', type=NameSpec,
help='specify the archive name')
parser.add_argument('--consider-checkpoints', action='store_true', dest='consider_checkpoints',
help='Show checkpoint archives in the repository contents list (default: hidden).')
parser.add_argument('mountpoint', metavar='MOUNTPOINT', type=str,

View file

@ -35,7 +35,7 @@ def async_wrapper(fn):
from .archiver import Archiver
from .archive import Archive, get_item_uid_gid
from .hashindex import FuseVersionsIndex
from .helpers import daemonize, daemonizing, signal_handler, format_file_size, Error
from .helpers import daemonize, daemonizing, signal_handler, format_file_size
from .helpers import HardLinkManager
from .helpers import msgpack
from .item import Item
@ -272,12 +272,6 @@ def __init__(self, key, manifest, repository, args, decrypted_repository):
def _create_filesystem(self):
self._create_dir(parent=1) # first call, create root dir (inode == 1)
if self._args.name:
if self.versions:
raise Error("for versions view, do not specify a single archive, "
"but always give the repository as location.")
self._process_archive(self._args.name)
else:
self.versions_index = FuseVersionsIndex()
for archive in self._manifest.archives.list_considering(self._args):
if self.versions:

View file

@ -847,22 +847,22 @@ def test_fuse_mount_hardlinks(self):
ignore_perms = ['-o', 'ignore_permissions,defer_permissions']
else:
ignore_perms = ['-o', 'ignore_permissions']
with self.fuse_mount(self.repository_location, mountpoint, '--name=test', '--strip-components=2', *ignore_perms), \
changedir(mountpoint):
with self.fuse_mount(self.repository_location, mountpoint, '-a', 'test', '--strip-components=2', *ignore_perms), \
changedir(os.path.join(mountpoint, 'test')):
assert os.stat('hardlink').st_nlink == 2
assert os.stat('subdir/hardlink').st_nlink == 2
assert open('subdir/hardlink', 'rb').read() == b'123456'
assert os.stat('aaaa').st_nlink == 2
assert os.stat('source2').st_nlink == 2
with self.fuse_mount(self.repository_location, mountpoint, 'input/dir1', '--name=test', *ignore_perms), \
changedir(mountpoint):
with self.fuse_mount(self.repository_location, mountpoint, 'input/dir1', '-a', 'test', *ignore_perms), \
changedir(os.path.join(mountpoint, 'test')):
assert os.stat('input/dir1/hardlink').st_nlink == 2
assert os.stat('input/dir1/subdir/hardlink').st_nlink == 2
assert open('input/dir1/subdir/hardlink', 'rb').read() == b'123456'
assert os.stat('input/dir1/aaaa').st_nlink == 2
assert os.stat('input/dir1/source2').st_nlink == 2
with self.fuse_mount(self.repository_location, mountpoint, '--name=test', *ignore_perms), \
changedir(mountpoint):
with self.fuse_mount(self.repository_location, mountpoint, '-a', 'test', *ignore_perms), \
changedir(os.path.join(mountpoint, 'test')):
assert os.stat('input/source').st_nlink == 4
assert os.stat('input/abba').st_nlink == 4
assert os.stat('input/dir1/hardlink').st_nlink == 4
@ -2527,13 +2527,12 @@ def has_noatime(some_file):
ignore_flags=True, ignore_xattrs=True)
self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'archive2', 'input'),
ignore_flags=True, ignore_xattrs=True)
# mount only 1 archive, its contents shall show up directly in mountpoint:
with self.fuse_mount(self.repository_location, mountpoint, '--name=archive'):
self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'input'),
with self.fuse_mount(self.repository_location, mountpoint, '-a', 'archive'):
self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'archive', 'input'),
ignore_flags=True, ignore_xattrs=True)
# regular file
in_fn = 'input/file1'
out_fn = os.path.join(mountpoint, 'input', 'file1')
out_fn = os.path.join(mountpoint, 'archive', 'input', 'file1')
# stat
sti1 = os.stat(in_fn)
sto1 = os.stat(out_fn)
@ -2554,7 +2553,7 @@ def has_noatime(some_file):
# hardlink (to 'input/file1')
if are_hardlinks_supported():
in_fn = 'input/hardlink'
out_fn = os.path.join(mountpoint, 'input', 'hardlink')
out_fn = os.path.join(mountpoint, 'archive', 'input', 'hardlink')
sti2 = os.stat(in_fn)
sto2 = os.stat(out_fn)
assert sti2.st_nlink == sto2.st_nlink == 2
@ -2562,7 +2561,7 @@ def has_noatime(some_file):
# symlink
if are_symlinks_supported():
in_fn = 'input/link1'
out_fn = os.path.join(mountpoint, 'input', 'link1')
out_fn = os.path.join(mountpoint, 'archive', 'input', 'link1')
sti = os.stat(in_fn, follow_symlinks=False)
sto = os.stat(out_fn, follow_symlinks=False)
assert sti.st_size == len('somewhere')
@ -2572,13 +2571,13 @@ def has_noatime(some_file):
assert os.readlink(in_fn) == os.readlink(out_fn)
# FIFO
if are_fifos_supported():
out_fn = os.path.join(mountpoint, 'input', 'fifo1')
out_fn = os.path.join(mountpoint, 'archive', 'input', 'fifo1')
sto = os.stat(out_fn)
assert stat.S_ISFIFO(sto.st_mode)
# list/read xattrs
try:
in_fn = 'input/fusexattr'
out_fn = os.fsencode(os.path.join(mountpoint, 'input', 'fusexattr'))
out_fn = os.fsencode(os.path.join(mountpoint, 'archive', 'input', 'fusexattr'))
if not xattr.XATTR_FAKEROOT and xattr.is_enabled(self.input_path):
assert sorted(no_selinux(xattr.listxattr(out_fn))) == [b'user.empty', b'user.foo', ]
assert xattr.getxattr(out_fn, b'user.foo') == b'bar'
@ -2648,12 +2647,12 @@ def test_fuse_allow_damaged_files(self):
self.cmd(f'--repo={self.repository_location}', 'check', '--repair', exit_code=0)
mountpoint = os.path.join(self.tmpdir, 'mountpoint')
with self.fuse_mount(self.repository_location, mountpoint, '--name=archive'):
with self.fuse_mount(self.repository_location, mountpoint, '-a', 'archive'):
with pytest.raises(OSError) as excinfo:
open(os.path.join(mountpoint, path))
open(os.path.join(mountpoint, 'archive', path))
assert excinfo.value.errno == errno.EIO
with self.fuse_mount(self.repository_location, mountpoint, '--name=archive', '-o', 'allow_damaged_files'):
open(os.path.join(mountpoint, path)).close()
with self.fuse_mount(self.repository_location, mountpoint, '-a', 'archive', '-o', 'allow_damaged_files'):
open(os.path.join(mountpoint, 'archive', path)).close()
@unittest.skipUnless(llfuse, 'llfuse not installed')
def test_fuse_mount_options(self):