Skip to content

Commit

Permalink
fix updating shadow_index also in put
Browse files Browse the repository at this point in the history
Guess the shadow_index should be in same state after both of these sequences
(let's assume that A is not in repo yet for simplicity, but it does not matter):

a) explicit delete: put(A), delete(A), put(A), resulting in: PUT A, DEL A, PUT A repo contents

b) implicit delete: put(A), put(A), resulting in: PUT A, DEL A, PUT A repo contents
  • Loading branch information
ThomasWaldmann committed Jan 18, 2021
1 parent d08d375 commit 5841886
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/borg/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ def get_many(self, ids, is_preloaded=False):

def _delete(self, id, segment, offset):
# common code used by put and delete
self.shadow_index.setdefault(id, []).append(segment)
self.segments[segment] -= 1
size = self.io.read(segment, offset, id, read_data=False)
self.storage_quota_use -= size
Expand Down Expand Up @@ -1217,7 +1218,6 @@ def delete(self, id, wait=True):
segment, offset = self.index.pop(id)
except KeyError:
raise self.ObjectNotFound(id, self.path) from None
self.shadow_index.setdefault(id, []).append(segment) # XXX should this be moved to _delete?
self._delete(id, segment, offset)

def async_response(self, wait=True):
Expand Down

0 comments on commit 5841886

Please sign in to comment.