1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-28 10:49:16 +00:00

avoid checking for non-existent files

if there's no attic cache, it's no use checking for individual files

this also makes the code a little clearer

also added comments
This commit is contained in:
Antoine Beaupré 2015-10-03 11:52:12 -04:00
parent 690541264e
commit 48b7c8cea3

View file

@ -178,22 +178,26 @@ def copy_cache_file(path):
print("no %s cache file found in %s" % (path, attic_file)) print("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
if os.path.exists(attic_cache_dir): if os.path.exists(attic_cache_dir):
if not os.path.exists(borg_cache_dir): if not os.path.exists(borg_cache_dir):
os.makedirs(borg_cache_dir) os.makedirs(borg_cache_dir)
# non-binary file that we don't need to convert, just copy
copy_cache_file('config') copy_cache_file('config')
# XXX: untested, because generating cache files is a PITA, see # we need to convert the headers of those files, copy first
# Archiver.do_create() for proof for cache in ['files', 'chunks']:
for cache in ['files', 'chunks']: copied = copy_cache_file(cache)
copied = copy_cache_file(cache) if copied:
if copied: caches.append(copied)
caches.append(copied)
for cache in caches: # actually convert the headers of the detected files
print("converting cache %s" % cache) for cache in caches:
if not dryrun: print("converting cache %s" % cache)
AtticRepositoryConverter.header_replace(cache, b'ATTICIDX', b'BORG_IDX') if not dryrun:
AtticRepositoryConverter.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
class AtticKeyfileKey(KeyfileKey): class AtticKeyfileKey(KeyfileKey):