mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-27 02:08:54 +00:00
Merge pull request #5636 from ThomasWaldmann/fix-put-updates-shadow-index
Fix "put updates shadow index"
This commit is contained in:
commit
dde13d7122
1 changed files with 7 additions and 7 deletions
|
@ -1191,13 +1191,9 @@ def put(self, id, data, wait=True):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.segments[segment] -= 1
|
# note: doing a delete first will do some bookkeeping,
|
||||||
size = self.io.read(segment, offset, id, read_data=False)
|
# like updating the shadow_index, quota, ...
|
||||||
self.storage_quota_use -= size
|
self._delete(id, segment, offset)
|
||||||
self.compact[segment] += size
|
|
||||||
segment, size = self.io.write_delete(id)
|
|
||||||
self.compact[segment] += size
|
|
||||||
self.segments.setdefault(segment, 0)
|
|
||||||
segment, offset = self.io.write_put(id, data)
|
segment, offset = self.io.write_put(id, data)
|
||||||
self.storage_quota_use += len(data) + self.io.put_header_fmt.size
|
self.storage_quota_use += len(data) + self.io.put_header_fmt.size
|
||||||
self.segments.setdefault(segment, 0)
|
self.segments.setdefault(segment, 0)
|
||||||
|
@ -1220,6 +1216,10 @@ def delete(self, id, wait=True):
|
||||||
segment, offset = self.index.pop(id)
|
segment, offset = self.index.pop(id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise self.ObjectNotFound(id, self.path) from None
|
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.shadow_index.setdefault(id, []).append(segment)
|
||||||
self.segments[segment] -= 1
|
self.segments[segment] -= 1
|
||||||
size = self.io.read(segment, offset, id, read_data=False)
|
size = self.io.read(segment, offset, id, read_data=False)
|
||||||
|
|
Loading…
Reference in a new issue