瀏覽代碼

also copy files cache verbatim

it seems the file cache does *not* have the ATTIC magic header (nor
does it have one in borg), so we don't need to edit the file - we just
copy it like a regular file.

while i'm here, simplify the cache conversion loop: it's no use
splitting the copy and the edition since the latter is so fast, just
do everything in one loop, which makes it much easier to read.
Antoine Beaupré 10 年之前
父節點
當前提交
5409cbaa67
共有 1 個文件被更改,包括 7 次插入10 次删除
  1. 7 10
      borg/upgrader.py

+ 7 - 10
borg/upgrader.py

@@ -184,20 +184,17 @@ class AtticRepositoryUpgrader(Repository):
             if not os.path.exists(borg_cache_dir):
                 os.makedirs(borg_cache_dir)
 
-            # non-binary file that we don't need to convert, just copy
-            copy_cache_file('config')
+            # file that we don't have a header to convert, just copy
+            for cache in ['config', 'files']:
+                copy_cache_file(cache)
 
             # we need to convert the headers of those files, copy first
-            for cache in ['files', 'chunks']:
+            for cache in ['chunks']:
                 copied = copy_cache_file(cache)
                 if copied:
-                    caches.append(copied)
-
-            # actually convert the headers of the detected files
-            for cache in caches:
-                print("converting cache %s" % cache)
-                if not dryrun:
-                    AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
+                    print("converting cache %s" % cache)
+                    if not dryrun:
+                        AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
 
 
 class AtticKeyfileKey(KeyfileKey):