mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
deduplicate code of put and delete, no functional change
This commit is contained in:
parent
e3d8b7c9ea
commit
5f32b5666a
1 changed files with 7 additions and 7 deletions
|
@ -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)
|
||||
|
@ -1221,6 +1217,10 @@ def delete(self, id, wait=True):
|
|||
except KeyError:
|
||||
raise self.ObjectNotFound(id, self.path) from None
|
||||
self.shadow_index.setdefault(id, []).append(segment)
|
||||
self._delete(id, segment, offset)
|
||||
|
||||
def _delete(self, id, segment, offset):
|
||||
# common code used by put and delete
|
||||
self.segments[segment] -= 1
|
||||
size = self.io.read(segment, offset, id, read_data=False)
|
||||
self.storage_quota_use -= size
|
||||
|
|
Loading…
Reference in a new issue