1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-02-22 14:11:27 +00:00

Revert "fix "attic info" all archives stats, fixes #183"

Fixed by jborg in master in a different way.

This reverts commit 212777d716.
This commit is contained in:
Thomas Waldmann 2015-04-21 20:50:19 +02:00
parent 212777d716
commit 38dd086e30
2 changed files with 6 additions and 10 deletions

View file

@ -14,7 +14,6 @@
import time
from io import BytesIO
from attic import xattr
from attic.cache import Cache
from attic.platform import acl_get, acl_set
from attic.chunker import Chunker
from attic.hashindex import ChunkIndex
@ -207,22 +206,19 @@ def save(self, name=None):
self.repository.commit()
self.cache.commit()
def calc_stats(self):
def calc_stats(self, cache):
def add(id):
count, size, csize = cache.chunks[id]
count, size, csize = self.cache.chunks[id]
stats.update(size, csize, count == 1)
cache.chunks[id] = count - 1, size, csize # dirties cache.chunks!
self.cache.chunks[id] = count - 1, size, csize
def add_file_chunks(chunks):
for id, _, _ in chunks:
add(id)
# This function is a bit evil since it abuses the cache to calculate
# the stats. The cache transaction must be rolled back afterwards.
cache = Cache(self.repository, self.key, self.manifest)
# the stats. The cache transaction must be rolled back afterwards
unpacker = msgpack.Unpacker(use_list=False)
cache.begin_txn()
stats = Statistics()
unpacker = msgpack.Unpacker(use_list=False)
add(self.id)
for id, chunk in zip(self.metadata[b'items'], self.repository.get_many(self.metadata[b'items'])):
add(id)

View file

@ -305,7 +305,7 @@ def do_info(self, args):
manifest, key = Manifest.load(repository)
cache = Cache(repository, key, manifest)
archive = Archive(repository, key, manifest, args.archive.archive, cache=cache)
stats = archive.calc_stats()
stats = archive.calc_stats(cache)
print('Name:', archive.name)
print('Fingerprint: %s' % hexlify(archive.id).decode('ascii'))
print('Hostname:', archive.metadata[b'hostname'])