From dbbd3f1b63d8cd75e9a320f889520f5973fc3aed Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 21 Oct 2020 19:00:26 +0000 Subject: [PATCH] Rather than error beginning a txn, create an empty files cache if it didn't exist before --- src/borg/cache.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/borg/cache.py b/src/borg/cache.py index 64eba5388..148143634 100644 --- a/src/borg/cache.py +++ b/src/borg/cache.py @@ -567,7 +567,11 @@ def begin_txn(self): 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