mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-19 04:41:50 +00:00
cache: Properly clean up txn.tmp after a failed commit
This commit is contained in:
parent
37cc63fc46
commit
9ae3d10a99
1 changed files with 5 additions and 3 deletions
|
@ -121,6 +121,9 @@ def commit(self):
|
||||||
def rollback(self):
|
def rollback(self):
|
||||||
"""Roll back partial and aborted transactions
|
"""Roll back partial and aborted transactions
|
||||||
"""
|
"""
|
||||||
|
# Remove partial transaction
|
||||||
|
if os.path.exists(os.path.join(self.path, 'txn.tmp')):
|
||||||
|
shutil.rmtree(os.path.join(self.path, 'txn.tmp'))
|
||||||
# Roll back active transaction
|
# Roll back active transaction
|
||||||
txn_dir = os.path.join(self.path, 'txn.active')
|
txn_dir = os.path.join(self.path, 'txn.active')
|
||||||
if os.path.exists(txn_dir):
|
if os.path.exists(txn_dir):
|
||||||
|
@ -128,9 +131,8 @@ def rollback(self):
|
||||||
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'), self.path)
|
shutil.copy(os.path.join(txn_dir, 'files'), self.path)
|
||||||
os.rename(txn_dir, os.path.join(self.path, 'txn.tmp'))
|
os.rename(txn_dir, os.path.join(self.path, 'txn.tmp'))
|
||||||
# Remove partial transaction
|
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'))
|
|
||||||
self.txn_active = False
|
self.txn_active = False
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
|
|
Loading…
Reference in a new issue