瀏覽代碼

Merge pull request #6628 from ThomasWaldmann/fix-files-cache-6353-1.1

fix transaction rollback: use files cache filename as found in txn.active
TW 3 年之前
父節點
當前提交
6a2ee5d921
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/borg/cache.py

+ 5 - 1
src/borg/cache.py

@@ -233,6 +233,10 @@ def files_cache_name():
     return 'files.' + suffix if suffix else 'files'
     return 'files.' + suffix if suffix else 'files'
 
 
 
 
+def discover_files_cache_name(path):
+    return [fn for fn in os.listdir(path) if fn == 'files' or fn.startswith('files.')][0]
+
+
 class CacheConfig:
 class CacheConfig:
     def __init__(self, repository, path=None, lock_wait=None):
     def __init__(self, repository, path=None, lock_wait=None):
         self.repository = repository
         self.repository = repository
@@ -621,7 +625,7 @@ class LocalCache(CacheStatsMixin):
         if os.path.exists(txn_dir):
         if os.path.exists(txn_dir):
             shutil.copy(os.path.join(txn_dir, 'config'), self.path)
             shutil.copy(os.path.join(txn_dir, 'config'), self.path)
             shutil.copy(os.path.join(txn_dir, 'chunks'), self.path)
             shutil.copy(os.path.join(txn_dir, 'chunks'), self.path)
-            shutil.copy(os.path.join(txn_dir, files_cache_name()), self.path)
+            shutil.copy(os.path.join(txn_dir, discover_files_cache_name(txn_dir)), self.path)
             os.rename(txn_dir, os.path.join(self.path, 'txn.tmp'))
             os.rename(txn_dir, os.path.join(self.path, 'txn.tmp'))
             if os.path.exists(os.path.join(self.path, 'txn.tmp')):
             if os.path.exists(os.path.join(self.path, 'txn.tmp')):
                 shutil.rmtree(os.path.join(self.path, 'txn.tmp'))
                 shutil.rmtree(os.path.join(self.path, 'txn.tmp'))