From dd0c69ac32d6c66b44040d0cae0445490c5995a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sun, 19 Apr 2015 23:45:05 +0200 Subject: [PATCH] Fix "All archives" output for attic info Closes #183 --- CHANGES | 1 + attic/archive.py | 2 +- attic/cache.py | 13 ++++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index b0d2b749d..f703b9b12 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Version 0.16 ------------ (bugfix release, released on X) +- Fix "All archives" output for attic info. (#183) - More user friendly error message when repository key file is not found (#236) - Fix parsing of iso 8601 timestamps with zero microseconds (#282) diff --git a/attic/archive.py b/attic/archive.py index 245e4d7d6..dd734b256 100644 --- a/attic/archive.py +++ b/attic/archive.py @@ -207,7 +207,7 @@ def save(self, name=None): def calc_stats(self, cache): 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 def add_file_chunks(chunks): diff --git a/attic/cache.py b/attic/cache.py index 3e0e50e08..95017b61b 100644 --- a/attic/cache.py +++ b/attic/cache.py @@ -93,11 +93,7 @@ def create(self): with open(os.path.join(self.path, 'files'), 'w') as fd: pass # empty file - def open(self): - if not os.path.isdir(self.path): - raise Exception('%s Does not look like an Attic cache' % self.path) - self.lock = UpgradableLock(os.path.join(self.path, 'config'), exclusive=True) - self.rollback() + def _do_open(self): self.config = RawConfigParser() self.config.read(os.path.join(self.path, 'config')) if self.config.getint('cache', 'version') != 1: @@ -110,6 +106,12 @@ def open(self): self.chunks = ChunkIndex.read(os.path.join(self.path, 'chunks').encode('utf-8')) self.files = None + def open(self): + if not os.path.isdir(self.path): + raise Exception('%s Does not look like an Attic cache' % self.path) + self.lock = UpgradableLock(os.path.join(self.path, 'config'), exclusive=True) + self.rollback() + def close(self): if self.lock: self.lock.release() @@ -181,6 +183,7 @@ def rollback(self): if os.path.exists(os.path.join(self.path, 'txn.tmp')): shutil.rmtree(os.path.join(self.path, 'txn.tmp')) self.txn_active = False + self._do_open() def sync(self): """Initializes cache by fetching and reading all archive indicies