1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-28 02:38:43 +00:00

Merge pull request #3852 from ThomasWaldmann/delete-commit-once

borg delete: only commit once, fixes #3823
This commit is contained in:
TW 2018-05-24 00:55:03 +02:00 committed by GitHub
commit 34d81d378a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1262,27 +1262,21 @@ def _delete_archives(self, args, repository):
logger.warning('Aborted.')
return self.exit_code
stats_logger = logging.getLogger('borg.output.stats')
if args.stats:
log_multi(DASHES, STATS_HEADER, logger=stats_logger)
stats = Statistics()
with Cache(repository, key, manifest, progress=args.progress, lock_wait=self.lock_wait) as cache:
for i, archive_name in enumerate(archive_names, 1):
logger.info('Deleting {} ({}/{}):'.format(archive_name, i, len(archive_names)))
archive = Archive(repository, key, manifest, archive_name, cache=cache)
stats = Statistics()
archive.delete(stats, progress=args.progress, forced=args.forced)
manifest.write()
repository.commit(save_space=args.save_space)
cache.commit()
logger.info("Archive deleted.")
if args.stats:
log_multi(stats.summary.format(label='Deleted data:', stats=stats),
DASHES, logger=stats_logger)
if args.forced == 0 and self.exit_code:
break
logger.info('Deleting archive: {} ({}/{})'.format(archive_name, i, len(archive_names)))
Archive(repository, key, manifest, archive_name, cache=cache).delete(
stats, progress=args.progress, forced=args.forced)
manifest.write()
repository.commit(save_space=args.save_space)
cache.commit()
if args.stats:
stats_logger.info(str(cache))
log_multi(DASHES,
STATS_HEADER,
stats.summary.format(label='Deleted data:', stats=stats),
str(cache),
DASHES, logger=logging.getLogger('borg.output.stats'))
return self.exit_code