1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

Merge pull request #5636 from ThomasWaldmann/fix-put-updates-shadow-index

Fix "put updates shadow index"
This commit is contained in:
TW 2021-01-29 17:31:35 +01:00 committed by GitHub
commit dde13d7122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1191,13 +1191,9 @@ def put(self, id, data, wait=True):
except KeyError:
pass
else:
self.segments[segment] -= 1
size = self.io.read(segment, offset, id, read_data=False)
self.storage_quota_use -= size
self.compact[segment] += size
segment, size = self.io.write_delete(id)
self.compact[segment] += size
self.segments.setdefault(segment, 0)
# note: doing a delete first will do some bookkeeping,
# like updating the shadow_index, quota, ...
self._delete(id, segment, offset)
segment, offset = self.io.write_put(id, data)
self.storage_quota_use += len(data) + self.io.put_header_fmt.size
self.segments.setdefault(segment, 0)
@ -1220,6 +1216,10 @@ def delete(self, id, wait=True):
segment, offset = self.index.pop(id)
except KeyError:
raise self.ObjectNotFound(id, self.path) from None
self._delete(id, segment, offset)
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)