mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-28 02:38:43 +00:00
borg delete: only commit once, fixes #3823
borg delete was slower than required when it deleted multiple archives as it committed repo and cache once per archive. borg prune (doing a similar job) is faster as it commits only once for all deleted archives. borg delete now also only commits once and also (similar to borg prune) only outputs a overall statistics for all deleted archives. log output of borg delete was made similar to borg prune.
This commit is contained in:
parent
1ac2bbb434
commit
a88a3153ad
1 changed files with 12 additions and 18 deletions
|
@ -1262,27 +1262,21 @@ def _delete_archives(self, args, repository):
|
||||||
logger.warning('Aborted.')
|
logger.warning('Aborted.')
|
||||||
return self.exit_code
|
return self.exit_code
|
||||||
|
|
||||||
stats_logger = logging.getLogger('borg.output.stats')
|
stats = Statistics()
|
||||||
if args.stats:
|
|
||||||
log_multi(DASHES, STATS_HEADER, logger=stats_logger)
|
|
||||||
|
|
||||||
with Cache(repository, key, manifest, progress=args.progress, lock_wait=self.lock_wait) as cache:
|
with Cache(repository, key, manifest, progress=args.progress, lock_wait=self.lock_wait) as cache:
|
||||||
for i, archive_name in enumerate(archive_names, 1):
|
for i, archive_name in enumerate(archive_names, 1):
|
||||||
logger.info('Deleting {} ({}/{}):'.format(archive_name, i, len(archive_names)))
|
logger.info('Deleting archive: {} ({}/{})'.format(archive_name, i, len(archive_names)))
|
||||||
archive = Archive(repository, key, manifest, archive_name, cache=cache)
|
Archive(repository, key, manifest, archive_name, cache=cache).delete(
|
||||||
stats = Statistics()
|
stats, progress=args.progress, forced=args.forced)
|
||||||
archive.delete(stats, progress=args.progress, forced=args.forced)
|
|
||||||
manifest.write()
|
manifest.write()
|
||||||
repository.commit(save_space=args.save_space)
|
repository.commit(save_space=args.save_space)
|
||||||
cache.commit()
|
cache.commit()
|
||||||
logger.info("Archive deleted.")
|
|
||||||
if args.stats:
|
if args.stats:
|
||||||
log_multi(stats.summary.format(label='Deleted data:', stats=stats),
|
log_multi(DASHES,
|
||||||
DASHES, logger=stats_logger)
|
STATS_HEADER,
|
||||||
if args.forced == 0 and self.exit_code:
|
stats.summary.format(label='Deleted data:', stats=stats),
|
||||||
break
|
str(cache),
|
||||||
if args.stats:
|
DASHES, logger=logging.getLogger('borg.output.stats'))
|
||||||
stats_logger.info(str(cache))
|
|
||||||
|
|
||||||
return self.exit_code
|
return self.exit_code
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue