]> arthur.barton.de Git - bup.git/commitdiff
_write_pack_idx_v2: close idx_map separately
authorRob Browning <rlb@defaultvalue.org>
Sun, 3 Jan 2016 17:59:17 +0000 (11:59 -0600)
committerRob Browning <rlb@defaultvalue.org>
Mon, 18 Jan 2016 17:30:09 +0000 (11:30 -0600)
...in its own finally block, so that the idx_f close will be attempted
even if the idx_map close throws an exception.

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

index bbac79fab6340d7414d24b54388b217c1e348135..50e1d47f2605584f41b368892cc922cf30be643f 100644 (file)
@@ -749,10 +749,12 @@ class PackWriter:
         try:
             idx_f.truncate(index_len)
             idx_map = mmap_readwrite(idx_f, close=False)
-            count = _helpers.write_idx(filename, idx_map, idx, self.count)
-            assert(count == self.count)
+            try:
+                count = _helpers.write_idx(filename, idx_map, idx, self.count)
+                assert(count == self.count)
+            finally:
+                idx_map.close()
         finally:
-            if idx_map: idx_map.close()
             idx_f.close()
 
         idx_f = open(filename, 'a+b')