From 98e4e6bc253f067cc5c45f046073d179e2d668d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 1 Oct 2015 09:35:17 -0400 Subject: [PATCH] lock repository when converting segments --- borg/converter.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/borg/converter.py b/borg/converter.py index 8261d9281..99de15170 100644 --- a/borg/converter.py +++ b/borg/converter.py @@ -2,6 +2,7 @@ from binascii import hexlify import os from .helpers import get_keys_dir +from .locking import UpgradableLock from .repository import Repository, MAGIC from .key import KeyfileKey, KeyfileNotFoundError @@ -22,7 +23,12 @@ class AtticRepositoryConverter(Repository): else: self.convert_keyfiles(keyfile, dryrun) self.close() + # partial open: just hold on to the lock + self.lock = UpgradableLock(os.path.join(self.path, 'lock'), + exclusive=True).acquire() self.convert_segments(segments, dryrun) + self.lock.release() + self.lock = None self.convert_cache(dryrun) @staticmethod @@ -34,6 +40,7 @@ class AtticRepositoryConverter(Repository): luckily the magic string length didn't change so we can just replace the 8 first bytes of all regular files in there.""" + print("converting %d segments..." % len(segments)) for filename in segments: print("converting segment %s in place" % filename) if not dryrun: