]> arthur.barton.de Git - bup.git/commitdiff
PackWriter _abort: try to always close the file
authorRob Browning <rlb@defaultvalue.org>
Sat, 2 Jan 2016 21:54:57 +0000 (15:54 -0600)
committerRob Browning <rlb@defaultvalue.org>
Mon, 18 Jan 2016 17:18:39 +0000 (11:18 -0600)
...even if the unlink fails.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/git.py

index fd0f3c92799393b1121228a6fbd6ebed064b2c43..2f331713578a599464ed5918e4fd1a99f70026d6 100644 (file)
@@ -685,8 +685,10 @@ class PackWriter:
         if f:
             self.idx = None
             self.file = None
-            f.close()
-            os.unlink(self.filename + '.pack')
+            try:
+                os.unlink(self.filename + '.pack')
+            finally:
+                f.close()
 
     def _end(self, run_midx=True):
         f = self.file