diff --git a/src/borg/fuse.py b/src/borg/fuse.py index dd77f4016..22dd4a4e1 100644 --- a/src/borg/fuse.py +++ b/src/borg/fuse.py @@ -46,7 +46,7 @@ def async_wrapper(fn): from .item import Item from .platform import uid2user, gid2group from .platformflags import is_darwin -from .remote import RemoteRepository # TODO 3 +from .remote3 import RemoteRepository3 def fuse_main(): @@ -546,7 +546,7 @@ def pop_option(options, key, present, not_present, wanted_type, int_base=0): self._create_filesystem() llfuse.init(self, mountpoint, options) if not foreground: - if isinstance(self.repository_uncached, RemoteRepository): + if isinstance(self.repository_uncached, RemoteRepository3): daemonize() else: with daemonizing() as (old_id, new_id): diff --git a/src/borg/repository3.py b/src/borg/repository3.py index 3aa9fe3eb..eb1827cf4 100644 --- a/src/borg/repository3.py +++ b/src/borg/repository3.py @@ -379,6 +379,11 @@ def preload(self, ids): def break_lock(self): 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): try: return self.store.load("config/manifest") diff --git a/src/borg/testsuite/archiver/mount_cmds.py b/src/borg/testsuite/archiver/mount_cmds.py index 136eb145f..0f05e92f2 100644 --- a/src/borg/testsuite/archiver/mount_cmds.py +++ b/src/borg/testsuite/archiver/mount_cmds.py @@ -7,7 +7,7 @@ from ... import xattr, platform from ...constants import * # NOQA -from ...locking import Lock +from ...locking3 import Lock from ...helpers import flags_noatime, flags_normal from .. import has_lchflags, llfuse from .. import changedir, no_selinux, same_ts_ns diff --git a/src/borg/testsuite/locking3.py b/src/borg/testsuite/locking3.py index 7a50d3dec..b9c4d3697 100644 --- a/src/borg/testsuite/locking3.py +++ b/src/borg/testsuite/locking3.py @@ -84,3 +84,17 @@ def test_lock_refresh_stale_removal(self, lockstore): assert len(lock_keys_b00) == 1 assert len(lock_keys_b21) == 0 # stale lock was ignored 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]