prune.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:borgcube 作者: enkore 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号