浏览代码

fix cascading failure with the index conversion code

this resolves bug #something where the index file could not be
converted, completely breaking conversion.

it seems that, during some refactoring, the index conversion code was
completely dropped. this was missed by the unit tests because the repo
can still be opened by the constructor even though the index is
invalid, so tests need improvements there.
Antoine Beaupré 9 年之前
父节点
当前提交
c4599d8ea4
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      borg/upgrader.py

+ 4 - 2
borg/upgrader.py

@@ -139,12 +139,14 @@ class AtticRepositoryUpgrader(Repository):
           `Cache.open()`, edit in place and then `Cache.close()` to
           make sure we have locking right
         """
-        caches = []
         transaction_id = self.get_index_transaction_id()
         if transaction_id is None:
             logger.warning('no index file found for repository %s' % self.path)
         else:
-            caches += [os.path.join(self.path, 'index.%d' % transaction_id).encode('utf-8')]
+            cache = os.path.join(self.path, 'index.%d' % transaction_id).encode('utf-8')
+            logger.info("converting index cache %s" % cache)
+            if not dryrun:
+                AtticRepositoryUpgrader.header_replace(cache, b'ATTICIDX', b'BORG_IDX')
 
         # copy of attic's get_cache_dir()
         attic_cache_dir = os.environ.get('ATTIC_CACHE_DIR',