From: Rob Browning Date: Sun, 3 Jan 2016 17:59:17 +0000 (-0600) Subject: _write_pack_idx_v2: close idx_map separately X-Git-Tag: 0.28-rc1~25 X-Git-Url: https://arthur.barton.de/gitweb/?p=bup.git;a=commitdiff_plain;h=d9fda6104edab546e25b1817f282dd18fc062998 _write_pack_idx_v2: close idx_map separately ...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 Tested-by: Rob Browning --- diff --git a/lib/bup/git.py b/lib/bup/git.py index bbac79f..50e1d47 100644 --- a/lib/bup/git.py +++ b/lib/bup/git.py @@ -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')