diff --git a/src/borg/locking.py b/src/borg/locking.py index e1b0c7fe09..c58f089d7c 100644 --- a/src/borg/locking.py +++ b/src/borg/locking.py @@ -156,7 +156,13 @@ def by_me(self): return os.path.exists(self.unique_name) def kill_stale_lock(self): - for name in os.listdir(self.path): + try: + names = os.listdir(self.path) + except FileNotFoundError: + # if another borg process won the race for killing a stale lock, we get here. + return False + + for name in names: try: host_pid, thread_str = name.rsplit('-', 1) host, pid_str = host_pid.rsplit('.', 1)