From fb68c6ff70acf8592894d83d353cb8f0c7735b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 15 Oct 2015 18:42:20 -0400 Subject: [PATCH] always convert the chunks cache we find it seems it is possible that the chunks files are copied but *not* converted. this may have happened here because the conversion was interrupted, although the specific scenario is still unclear (but it did happen during manual tests here). therefore reproducing this problem seems to be difficult, hence the lack of tests for this specific issue. since we consider the header replacement code to be safe, that we always convert shouldn't pose any additional threat to the existing borg chunk cache. --- borg/upgrader.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/borg/upgrader.py b/borg/upgrader.py index daf090998..6bb5055c7 100644 --- a/borg/upgrader.py +++ b/borg/upgrader.py @@ -166,23 +166,23 @@ class AtticRepositoryUpgrader(Repository): :params path: the basename of the cache file to copy (example: "files" or "chunks") as a string - :returns: the borg file that was created or None if non - was created. + :returns: the borg file that was created or None if no + Attic cache file was found. """ attic_file = os.path.join(attic_cache_dir, path) if os.path.exists(attic_file): borg_file = os.path.join(borg_cache_dir, path) if os.path.exists(borg_file): - logger.warning("borg cache file already exists in %s, skipping conversion of %s" % (borg_file, attic_file)) + logger.warning("borg cache file already exists in %s, not copying from Attic" % (borg_file)) else: logger.info("copying attic cache file from %s to %s" % (attic_file, borg_file)) if not dryrun: shutil.copyfile(attic_file, borg_file) - return borg_file + return borg_file else: logger.warning("no %s cache file found in %s" % (path, attic_file)) - return None + return None # XXX: untested, because generating cache files is a PITA, see # Archiver.do_create() for proof @@ -196,11 +196,10 @@ class AtticRepositoryUpgrader(Repository): # we need to convert the headers of those files, copy first for cache in ['chunks']: - copied = copy_cache_file(cache) - if copied: - logger.info("converting cache %s" % cache) - if not dryrun: - AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX') + cache = copy_cache_file(cache) + logger.info("converting cache %s" % cache) + if not dryrun: + AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX') class AtticKeyfileKey(KeyfileKey):