mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 10:18:12 +00:00
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.
This commit is contained in:
parent
c4599d8ea4
commit
fb68c6ff70
1 changed files with 9 additions and 10 deletions
|
@ -166,15 +166,15 @@ def copy_cache_file(path):
|
||||||
:params path: the basename of the cache file to copy
|
:params path: the basename of the cache file to copy
|
||||||
(example: "files" or "chunks") as a string
|
(example: "files" or "chunks") as a string
|
||||||
|
|
||||||
:returns: the borg file that was created or None if non
|
:returns: the borg file that was created or None if no
|
||||||
was created.
|
Attic cache file was found.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
attic_file = os.path.join(attic_cache_dir, path)
|
attic_file = os.path.join(attic_cache_dir, path)
|
||||||
if os.path.exists(attic_file):
|
if os.path.exists(attic_file):
|
||||||
borg_file = os.path.join(borg_cache_dir, path)
|
borg_file = os.path.join(borg_cache_dir, path)
|
||||||
if os.path.exists(borg_file):
|
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:
|
else:
|
||||||
logger.info("copying attic cache file from %s to %s" % (attic_file, borg_file))
|
logger.info("copying attic cache file from %s to %s" % (attic_file, borg_file))
|
||||||
if not dryrun:
|
if not dryrun:
|
||||||
|
@ -196,8 +196,7 @@ def copy_cache_file(path):
|
||||||
|
|
||||||
# we need to convert the headers of those files, copy first
|
# we need to convert the headers of those files, copy first
|
||||||
for cache in ['chunks']:
|
for cache in ['chunks']:
|
||||||
copied = copy_cache_file(cache)
|
cache = copy_cache_file(cache)
|
||||||
if copied:
|
|
||||||
logger.info("converting cache %s" % cache)
|
logger.info("converting cache %s" % cache)
|
||||||
if not dryrun:
|
if not dryrun:
|
||||||
AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
|
AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
|
||||||
|
|
Loading…
Reference in a new issue