mirror of
https://github.com/borgbackup/borg.git
synced 2025-01-01 12:45:34 +00:00
fuse/mount code and test fixes
This commit is contained in:
parent
3e7a4cd814
commit
cb9ff3b490
4 changed files with 22 additions and 3 deletions
|
@ -46,7 +46,7 @@ def async_wrapper(fn):
|
||||||
from .item import Item
|
from .item import Item
|
||||||
from .platform import uid2user, gid2group
|
from .platform import uid2user, gid2group
|
||||||
from .platformflags import is_darwin
|
from .platformflags import is_darwin
|
||||||
from .remote import RemoteRepository # TODO 3
|
from .remote3 import RemoteRepository3
|
||||||
|
|
||||||
|
|
||||||
def fuse_main():
|
def fuse_main():
|
||||||
|
@ -546,7 +546,7 @@ def pop_option(options, key, present, not_present, wanted_type, int_base=0):
|
||||||
self._create_filesystem()
|
self._create_filesystem()
|
||||||
llfuse.init(self, mountpoint, options)
|
llfuse.init(self, mountpoint, options)
|
||||||
if not foreground:
|
if not foreground:
|
||||||
if isinstance(self.repository_uncached, RemoteRepository):
|
if isinstance(self.repository_uncached, RemoteRepository3):
|
||||||
daemonize()
|
daemonize()
|
||||||
else:
|
else:
|
||||||
with daemonizing() as (old_id, new_id):
|
with daemonizing() as (old_id, new_id):
|
||||||
|
|
|
@ -379,6 +379,11 @@ def preload(self, ids):
|
||||||
def break_lock(self):
|
def break_lock(self):
|
||||||
Lock(self.store).break_lock()
|
Lock(self.store).break_lock()
|
||||||
|
|
||||||
|
def migrate_lock(self, old_id, new_id):
|
||||||
|
# note: only needed for local repos
|
||||||
|
if self.lock is not None:
|
||||||
|
self.lock.migrate_lock(old_id, new_id)
|
||||||
|
|
||||||
def get_manifest(self):
|
def get_manifest(self):
|
||||||
try:
|
try:
|
||||||
return self.store.load("config/manifest")
|
return self.store.load("config/manifest")
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
from ... import xattr, platform
|
from ... import xattr, platform
|
||||||
from ...constants import * # NOQA
|
from ...constants import * # NOQA
|
||||||
from ...locking import Lock
|
from ...locking3 import Lock
|
||||||
from ...helpers import flags_noatime, flags_normal
|
from ...helpers import flags_noatime, flags_normal
|
||||||
from .. import has_lchflags, llfuse
|
from .. import has_lchflags, llfuse
|
||||||
from .. import changedir, no_selinux, same_ts_ns
|
from .. import changedir, no_selinux, same_ts_ns
|
||||||
|
|
|
@ -84,3 +84,17 @@ def test_lock_refresh_stale_removal(self, lockstore):
|
||||||
assert len(lock_keys_b00) == 1
|
assert len(lock_keys_b00) == 1
|
||||||
assert len(lock_keys_b21) == 0 # stale lock was ignored
|
assert len(lock_keys_b21) == 0 # stale lock was ignored
|
||||||
assert len(list(lock.store.list("locks"))) == 0 # stale lock was removed from store
|
assert len(list(lock.store.list("locks"))) == 0 # stale lock was removed from store
|
||||||
|
|
||||||
|
def test_migrate_lock(self, lockstore):
|
||||||
|
old_id, new_id = ID1, ID2
|
||||||
|
assert old_id[1] != new_id[1] # different PIDs (like when doing daemonize())
|
||||||
|
lock = Lock(lockstore, id=old_id).acquire()
|
||||||
|
old_locks = lock._find_locks(only_mine=True)
|
||||||
|
assert lock.id == old_id # lock is for old id / PID
|
||||||
|
lock.migrate_lock(old_id, new_id) # fix the lock
|
||||||
|
assert lock.id == new_id # lock corresponds to the new id / PID
|
||||||
|
new_locks = lock._find_locks(only_mine=True)
|
||||||
|
assert old_locks != new_locks
|
||||||
|
assert len(old_locks) == len(new_locks) == 1
|
||||||
|
assert old_locks[0]["hostid"] == old_id[0]
|
||||||
|
assert new_locks[0]["hostid"] == new_id[0]
|
||||||
|
|
Loading…
Reference in a new issue