mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-24 07:01:59 +00:00
delete archive: consider part files correctly for stats, see #4507
This commit is contained in:
parent
df5641ad27
commit
502ebe63be
3 changed files with 13 additions and 11 deletions
|
@ -845,9 +845,9 @@ def fetch_async_response(wait=True):
|
||||||
error = True
|
error = True
|
||||||
return exception_ignored # must not return None here
|
return exception_ignored # must not return None here
|
||||||
|
|
||||||
def chunk_decref(id, stats):
|
def chunk_decref(id, stats, part=False):
|
||||||
try:
|
try:
|
||||||
self.cache.chunk_decref(id, stats, wait=False)
|
self.cache.chunk_decref(id, stats, wait=False, part=part)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
cid = bin_to_hex(id)
|
cid = bin_to_hex(id)
|
||||||
raise ChunksIndexError(cid)
|
raise ChunksIndexError(cid)
|
||||||
|
@ -869,8 +869,9 @@ def chunk_decref(id, stats):
|
||||||
for item in unpacker:
|
for item in unpacker:
|
||||||
item = Item(internal_dict=item)
|
item = Item(internal_dict=item)
|
||||||
if 'chunks' in item:
|
if 'chunks' in item:
|
||||||
|
part = not self.consider_part_files and 'part' in item
|
||||||
for chunk_id, size, csize in item.chunks:
|
for chunk_id, size, csize in item.chunks:
|
||||||
chunk_decref(chunk_id, stats)
|
chunk_decref(chunk_id, stats, part=part)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
# if items metadata spans multiple chunks and one chunk got dropped somehow,
|
# if items metadata spans multiple chunks and one chunk got dropped somehow,
|
||||||
# it could be that unpacker yields bad types
|
# it could be that unpacker yields bad types
|
||||||
|
|
|
@ -1132,8 +1132,9 @@ def _delete_archives(self, args, repository):
|
||||||
msg = 'Would delete archive: {} ({}/{})' if dry_run else 'Deleting archive: {} ({}/{})'
|
msg = 'Would delete archive: {} ({}/{})' if dry_run else 'Deleting archive: {} ({}/{})'
|
||||||
logger.info(msg.format(format_archive(manifest.archives[archive_name]), i, len(archive_names)))
|
logger.info(msg.format(format_archive(manifest.archives[archive_name]), i, len(archive_names)))
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
Archive(repository, key, manifest, archive_name, cache=cache).delete(
|
archive = Archive(repository, key, manifest, archive_name, cache=cache,
|
||||||
stats, progress=args.progress, forced=args.forced)
|
consider_part_files=args.consider_part_files)
|
||||||
|
archive.delete(stats, progress=args.progress, forced=args.forced)
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
manifest.write()
|
manifest.write()
|
||||||
repository.commit(compact=False, save_space=args.save_space)
|
repository.commit(compact=False, save_space=args.save_space)
|
||||||
|
|
|
@ -909,16 +909,16 @@ def chunk_incref(self, id, stats, size=None, part=False):
|
||||||
stats.update(_size, csize, False, part=part)
|
stats.update(_size, csize, False, part=part)
|
||||||
return ChunkListEntry(id, _size, csize)
|
return ChunkListEntry(id, _size, csize)
|
||||||
|
|
||||||
def chunk_decref(self, id, stats, wait=True):
|
def chunk_decref(self, id, stats, wait=True, part=False):
|
||||||
if not self.txn_active:
|
if not self.txn_active:
|
||||||
self.begin_txn()
|
self.begin_txn()
|
||||||
count, size, csize = self.chunks.decref(id)
|
count, size, csize = self.chunks.decref(id)
|
||||||
if count == 0:
|
if count == 0:
|
||||||
del self.chunks[id]
|
del self.chunks[id]
|
||||||
self.repository.delete(id, wait=wait)
|
self.repository.delete(id, wait=wait)
|
||||||
stats.update(-size, -csize, True)
|
stats.update(-size, -csize, True, part=part)
|
||||||
else:
|
else:
|
||||||
stats.update(-size, -csize, False)
|
stats.update(-size, -csize, False, part=part)
|
||||||
|
|
||||||
def file_known_and_unchanged(self, path_hash, st):
|
def file_known_and_unchanged(self, path_hash, st):
|
||||||
"""
|
"""
|
||||||
|
@ -1057,16 +1057,16 @@ def chunk_incref(self, id, stats, size=None, part=False):
|
||||||
stats.update(size, csize, False, part=part)
|
stats.update(size, csize, False, part=part)
|
||||||
return ChunkListEntry(id, size, csize)
|
return ChunkListEntry(id, size, csize)
|
||||||
|
|
||||||
def chunk_decref(self, id, stats, wait=True):
|
def chunk_decref(self, id, stats, wait=True, part=False):
|
||||||
if not self._txn_active:
|
if not self._txn_active:
|
||||||
self.begin_txn()
|
self.begin_txn()
|
||||||
count, size, csize = self.chunks.decref(id)
|
count, size, csize = self.chunks.decref(id)
|
||||||
if count == 0:
|
if count == 0:
|
||||||
del self.chunks[id]
|
del self.chunks[id]
|
||||||
self.repository.delete(id, wait=wait)
|
self.repository.delete(id, wait=wait)
|
||||||
stats.update(-size, -csize, True)
|
stats.update(-size, -csize, True, part=part)
|
||||||
else:
|
else:
|
||||||
stats.update(-size, -csize, False)
|
stats.update(-size, -csize, False, part=part)
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
if not self._txn_active:
|
if not self._txn_active:
|
||||||
|
|
Loading…
Reference in a new issue