From 9ae3d10a990ac784e484a9e83468b3a77df360e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sun, 30 Mar 2014 22:46:57 +0200 Subject: [PATCH] cache: Properly clean up txn.tmp after a failed commit --- attic/cache.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/attic/cache.py b/attic/cache.py index 72a14b8b9..65362ff39 100644 --- a/attic/cache.py +++ b/attic/cache.py @@ -121,6 +121,9 @@ 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): @@ -128,9 +131,8 @@ def rollback(self): shutil.copy(os.path.join(txn_dir, 'chunks'), self.path) shutil.copy(os.path.join(txn_dir, 'files'), self.path) 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')) + 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):