1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-26 01:09:08 +00:00

Fix cache rollback logic race condition

This commit is contained in:
Jonas Borgström 2011-08-14 14:50:56 +02:00
parent 1c207d5686
commit ebbab77a86

View file

@ -69,7 +69,7 @@ def _read_files(self):
break
u.feed(data)
for hash, item in u:
if item[0] < 8:
if item[0] < 10:
self.files[hash] = (item[0] + 1,) + item[1:]
def begin_txn(self):
@ -104,16 +104,16 @@ def commit(self):
def rollback(self):
"""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
txn_dir = os.path.join(self.path, 'txn.active')
if os.path.exists(txn_dir):
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, 'files'), self.path)
shutil.rmtree(txn_dir)
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')):
shutil.rmtree(os.path.join(self.path, 'txn.tmp'))
self.txn_active = False
def sync(self):