Browse Source

Fix "All archives" output for attic info

Closes #183
Jonas Borgström 10 years ago
parent
commit
dd0c69ac32
3 changed files with 10 additions and 6 deletions
  1. 1 0
      CHANGES
  2. 1 1
      attic/archive.py
  3. 8 5
      attic/cache.py

+ 1 - 0
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)
 

+ 1 - 1
attic/archive.py

@@ -207,7 +207,7 @@ class Archive:
 
     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):

+ 8 - 5
attic/cache.py

@@ -93,11 +93,7 @@ class Cache(object):
         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 @@ class Cache(object):
         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 @@ class Cache(object):
             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