From 26e8ff2cbc449bc49bc5e3bad3d51e8c757cc763 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Tue, 16 Aug 2016 12:45:33 +0200 Subject: [PATCH] Repository: don't use defaultdict for shadow index avoids errors by accidentally inserting an empty list and makes it more clear. --- src/borg/repository.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/borg/repository.py b/src/borg/repository.py index 097c64bcd..a095ca7c8 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -113,10 +113,9 @@ class Repository: self.index = None # This is an index of shadowed log entries during this transaction. Consider the following sequence: # segment_n PUT A, segment_x DELETE A - # After the "DELETE A" in segment_x the shadow index will contain "A -> (n,)". - self.shadow_index = defaultdict(list) + # After the "DELETE A" in segment_x the shadow index will contain "A -> [n]". + self.shadow_index = {} self._active_txn = False - self.lock_wait = lock_wait self.do_lock = lock self.do_create = create @@ -741,7 +740,7 @@ class Repository: segment, offset = self.index.pop(id) except KeyError: raise self.ObjectNotFound(id, self.path) from None - self.shadow_index[id].append(segment) + self.shadow_index.setdefault(id, []).append(segment) self.segments[segment] -= 1 size = self.io.read(segment, offset, id, read_data=False) self.compact[segment] += size