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
|
||||
return exception_ignored # must not return None here
|
||||
|
||||
def chunk_decref(id, stats):
|
||||
def chunk_decref(id, stats, part=False):
|
||||
try:
|
||||
self.cache.chunk_decref(id, stats, wait=False)
|
||||
self.cache.chunk_decref(id, stats, wait=False, part=part)
|
||||
except KeyError:
|
||||
cid = bin_to_hex(id)
|
||||
raise ChunksIndexError(cid)
|
||||
|
@ -869,8 +869,9 @@ def chunk_decref(id, stats):
|
|||
for item in unpacker:
|
||||
item = Item(internal_dict=item)
|
||||
if 'chunks' in item:
|
||||
part = not self.consider_part_files and 'part' in item
|
||||
for chunk_id, size, csize in item.chunks:
|
||||
chunk_decref(chunk_id, stats)
|
||||
chunk_decref(chunk_id, stats, part=part)
|
||||
except (TypeError, ValueError):
|
||||
# if items metadata spans multiple chunks and one chunk got dropped somehow,
|
||||
# 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: {} ({}/{})'
|
||||
logger.info(msg.format(format_archive(manifest.archives[archive_name]), i, len(archive_names)))
|
||||
if not dry_run:
|
||||
Archive(repository, key, manifest, archive_name, cache=cache).delete(
|
||||
stats, progress=args.progress, forced=args.forced)
|
||||
archive = Archive(repository, key, manifest, archive_name, cache=cache,
|
||||
consider_part_files=args.consider_part_files)
|
||||
archive.delete(stats, progress=args.progress, forced=args.forced)
|
||||
if not dry_run:
|
||||
manifest.write()
|
||||
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)
|
||||
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:
|
||||
self.begin_txn()
|
||||
count, size, csize = self.chunks.decref(id)
|
||||
if count == 0:
|
||||
del self.chunks[id]
|
||||
self.repository.delete(id, wait=wait)
|
||||
stats.update(-size, -csize, True)
|
||||
stats.update(-size, -csize, True, part=part)
|
||||
else:
|
||||
stats.update(-size, -csize, False)
|
||||
stats.update(-size, -csize, False, part=part)
|
||||
|
||||
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)
|
||||
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:
|
||||
self.begin_txn()
|
||||
count, size, csize = self.chunks.decref(id)
|
||||
if count == 0:
|
||||
del self.chunks[id]
|
||||
self.repository.delete(id, wait=wait)
|
||||
stats.update(-size, -csize, True)
|
||||
stats.update(-size, -csize, True, part=part)
|
||||
else:
|
||||
stats.update(-size, -csize, False)
|
||||
stats.update(-size, -csize, False, part=part)
|
||||
|
||||
def commit(self):
|
||||
if not self._txn_active:
|
||||
|
|
Loading…
Reference in a new issue