def prune_archives(self, archives, repository):
"""
Prune list of two tuples (delete, archive), all of which must be in the same `Repository`.
Return `Statistics`.
"""
# TODO Maybe commit some stuff here after a while, because this can seriously take some time.
stats = Statistics()
with open_repository(repository) as borg_repository:
manifest, key = Manifest.load(borg_repository)
with Cache(borg_repository, key, manifest, lock_wait=1) as cache:
for delete, archive in archives:
assert archive.repository == repository
if delete:
log.info('Deleting archive %s [%s]', archive.name, archive.id)
archive.delete(manifest, stats, cache)
else:
log.info('Skipping archive %s [%s]', archive.name, archive.id)
manifest.write()
borg_repository.commit()
cache.commit()
transaction.commit()
log.error(stats.summary.format(label='Deleted data:', stats=stats))
return stats
评论列表
文章目录