mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +00:00
prune: Delete all archives in a single transaction
This will improve performance and make the whole operation atomic
This commit is contained in:
parent
80e7e637cc
commit
839dd94a59
2 changed files with 10 additions and 6 deletions
|
@ -316,7 +316,7 @@ def restore_attrs(self, path, item, symlink=False, fd=None):
|
|||
elif not symlink:
|
||||
os.utime(path, (item[b'mtime'] / 10**9, item[b'mtime'] / 10**9))
|
||||
|
||||
def delete(self, cache):
|
||||
def delete(self):
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
for id_, data in zip(self.metadata[b'items'], self.repository.get_many(self.metadata[b'items'])):
|
||||
unpacker.feed(self.key.decrypt(id_, data))
|
||||
|
@ -328,9 +328,6 @@ def delete(self, cache):
|
|||
|
||||
self.cache.chunk_decref(self.id)
|
||||
del self.manifest.archives[self.name]
|
||||
self.manifest.write()
|
||||
self.repository.commit()
|
||||
cache.commit()
|
||||
|
||||
def stat_attrs(self, st, path):
|
||||
item = {
|
||||
|
|
|
@ -219,7 +219,10 @@ def do_delete(self, args):
|
|||
manifest, key = Manifest.load(repository)
|
||||
cache = Cache(repository, key, manifest)
|
||||
archive = Archive(repository, key, manifest, args.archive.archive, cache=cache)
|
||||
archive.delete(cache)
|
||||
archive.delete()
|
||||
manifest.write()
|
||||
repository.commit()
|
||||
cache.commit()
|
||||
return self.exit_code
|
||||
|
||||
def do_mount(self, args):
|
||||
|
@ -338,7 +341,11 @@ def do_prune(self, args):
|
|||
self.print_verbose('Would prune: %s' % format_archive(archive))
|
||||
else:
|
||||
self.print_verbose('Pruning archive: %s' % format_archive(archive))
|
||||
archive.delete(cache)
|
||||
archive.delete()
|
||||
if to_delete and not args.dry_run:
|
||||
manifest.write()
|
||||
repository.commit()
|
||||
cache.commit()
|
||||
return self.exit_code
|
||||
|
||||
helptext = {}
|
||||
|
|
Loading…
Reference in a new issue