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:
|
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)
|
||||||
|
@ -1221,6 +1217,10 @@ def delete(self, id, wait=True):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise self.ObjectNotFound(id, self.path) from None
|
raise self.ObjectNotFound(id, self.path) from None
|
||||||
self.shadow_index.setdefault(id, []).append(segment)
|
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
|
self.segments[segment] -= 1
|
||||||
size = self.io.read(segment, offset, id, read_data=False)
|
size = self.io.read(segment, offset, id, read_data=False)
|
||||||
self.storage_quota_use -= size
|
self.storage_quota_use -= size
|
||||||
|
|
Loading…
Reference in a new issue