浏览代码

Rather than error beginning a txn, create an empty files cache if it didn't exist before

Luke Dashjr 4 年之前
父节点
当前提交
dbbd3f1b63
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/borg/cache.py

+ 5 - 1
src/borg/cache.py

@@ -567,7 +567,11 @@ class LocalCache(CacheStatsMixin):
         pi.output('Initializing cache transaction: Reading chunks')
         shutil.copy(os.path.join(self.path, 'chunks'), txn_dir)
         pi.output('Initializing cache transaction: Reading files')
-        shutil.copy(os.path.join(self.path, files_cache_name()), txn_dir)
+        try:
+            shutil.copy(os.path.join(self.path, files_cache_name()), txn_dir)
+        except FileNotFoundError:
+            with SaveFile(os.path.join(txn_dir, files_cache_name()), binary=True):
+                pass  # empty file
         os.rename(os.path.join(self.path, 'txn.tmp'),
                   os.path.join(self.path, 'txn.active'))
         self.txn_active = True