Browse Source

Fix exception during "attic create" with repeated files

Closes #39
Jonas Borgström 11 years ago
parent
commit
d44fa850cd
3 changed files with 8 additions and 1 deletions
  1. 1 0
      CHANGES
  2. 2 1
      attic/cache.py
  3. 5 0
      attic/testsuite/archiver.py

+ 1 - 0
CHANGES

@@ -10,6 +10,7 @@ Version 0.11
 
 - New "check" command for repository consistency checking (#24)
 - Documentation improvements
+- Fix exception during "attic create" with repeated files (#39)
 
 Version 0.10
 ------------

+ 2 - 1
attic/cache.py

@@ -206,7 +206,8 @@ class Cache(object):
         if (entry and entry[3] == st_mtime_ns(st)
             and entry[2] == st.st_size and entry[1] == st.st_ino):
             # reset entry age
-            self.files[path_hash][0] = 0
+            if entry[0] != 0:
+                self.files[path_hash][0] = 0
             return entry[4]
         else:
             return None

+ 5 - 0
attic/testsuite/archiver.py

@@ -179,6 +179,11 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         self.assert_not_in('..', output)
         self.assert_in(' input/dir1/dir2/file', output)
 
+    def test_repeated_files(self):
+        self.create_regual_file('file1', size=1024 * 80)
+        self.attic('init', self.repository_location)
+        self.attic('create', self.repository_location + '::test', 'input', 'input')
+
     def test_overwrite(self):
         self.create_regual_file('file1', size=1024 * 80)
         self.create_regual_file('dir2/file2', size=1024 * 80)