mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-09 08:51:54 -04:00
Merge branch 'merge' into merge-all
This commit is contained in:
commit
1cafd12e19
2 changed files with 9 additions and 6 deletions
|
|
@ -14,6 +14,7 @@ import sys
|
|||
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
|
||||
|
|
@ -223,20 +224,22 @@ class Archive:
|
|||
self.repository.commit()
|
||||
self.cache.commit()
|
||||
|
||||
def calc_stats(self, cache):
|
||||
def calc_stats(self):
|
||||
def add(id):
|
||||
count, size, csize = self.cache.chunks[id]
|
||||
count, size, csize = cache.chunks[id]
|
||||
stats.update(size, csize, count == 1)
|
||||
self.cache.chunks[id] = count - 1, size, csize
|
||||
cache.chunks[id] = count - 1, size, csize # dirties cache.chunks!
|
||||
|
||||
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
|
||||
unpacker = msgpack.Unpacker(use_list=False)
|
||||
# the stats. The cache transaction must be rolled back afterwards.
|
||||
cache = Cache(self.repository, self.key, self.manifest)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ Type "Yes I am sure" if you understand this and want to continue.\n""")
|
|||
manifest, key = Manifest.load(repository)
|
||||
cache = Cache(repository, key, manifest, do_files=args.cache_files)
|
||||
archive = Archive(repository, key, manifest, args.archive.archive, cache=cache)
|
||||
stats = archive.calc_stats(cache)
|
||||
stats = archive.calc_stats()
|
||||
print('Name:', archive.name)
|
||||
print('Fingerprint: %s' % hexlify(archive.id).decode('ascii'))
|
||||
print('Hostname:', archive.metadata[b'hostname'])
|
||||
|
|
|
|||
Loading…
Reference in a new issue