From 4c178e0010b9979093f7afdb17a63ba7a4c39128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Wed, 27 Oct 2010 21:01:57 +0200 Subject: [PATCH] Various improvements. --- darc/archiver.py | 2 +- darc/cache.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/darc/archiver.py b/darc/archiver.py index 13eacb37a..bc912b60a 100644 --- a/darc/archiver.py +++ b/darc/archiver.py @@ -57,7 +57,7 @@ class Archiver(object): archive.list() else: for archive in Archive.list_archives(store, crypto): - print archive.metadata['name'] + print '%(name)-20s %(time)s' % archive.metadata return self.exit_code_from_logger() def do_verify(self, args): diff --git a/darc/cache.py b/darc/cache.py index 1a9c7afc0..e22b0ca65 100644 --- a/darc/cache.py +++ b/darc/cache.py @@ -51,13 +51,17 @@ class Cache(object): self.chunk_counts[id] = 1, size self.save() + def filter_file_chunks(self): + for key, value in self.file_chunks.iteritems(): + if value[0] < 8: + yield key, (value[0] + 1,) + value[1:] + def save(self): assert self.store.state == self.store.OPEN cache = {'version': 1, 'tid': self.store.tid, 'chunk_counts': self.chunk_counts, - 'file_chunks': dict(ifilter(lambda i: i[1][0] < 8, - self.file_chunks.iteritems())), + 'file_chunks': dict(self.filter_file_chunks()), } data, hash = self.crypto.encrypt_create(msgpack.packb(cache)) cachedir = os.path.dirname(self.path)