Ver Fonte

Merge pull request #445 from anarcat/status-bug

add test for the weird unchanged file status
TW há 9 anos atrás
pai
commit
d1377e5e15
3 ficheiros alterados com 29 adições e 4 exclusões
  1. 19 0
      borg/testsuite/archiver.py
  2. 9 3
      docs/faq.rst
  3. 1 1
      docs/usage.rst

+ 19 - 0
borg/testsuite/archiver.py

@@ -704,6 +704,25 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         output = self.cmd('create', '--no-progress', self.repository_location + '::test6', 'input', fork=True)
         self.assert_not_in("\r", output)
 
+    def test_file_status(self):
+        """test that various file status show expected results
+
+        clearly incomplete: only tests for the weird "unchanged" status for now"""
+        now = time.time()
+        self.create_regular_file('file1', size=1024 * 80)
+        os.utime('input/file1', (now - 5, now - 5)) # 5 seconds ago
+        self.create_regular_file('file2', size=1024 * 80)
+        self.cmd('init', self.repository_location)
+        output = self.cmd('create', '--verbose', self.repository_location + '::test', 'input')
+        self.assert_in("A input/file1", output)
+        self.assert_in("A input/file2", output)
+        # should find first file as unmodified
+        output = self.cmd('create', '--verbose', self.repository_location + '::test1', 'input')
+        self.assert_in("U input/file1", output)
+        # this is expected, although surprising, for why, see:
+        # http://borgbackup.readthedocs.org/en/latest/faq.html#i-am-seeing-a-added-status-for-a-unchanged-file
+        self.assert_in("A input/file2", output)
+
     def test_cmdline_compatibility(self):
         self.create_regular_file('file1', size=1024 * 80)
         self.cmd('init', self.repository_location)

+ 9 - 3
docs/faq.rst

@@ -165,12 +165,14 @@ Yes, if you want to detect accidental data damage (like bit rot), use the
 If you want to be able to detect malicious tampering also, use a encrypted
 repo. It will then be able to check using CRCs and HMACs.
 
+.. _a_status_oddity:
+
 I am seeing 'A' (added) status for a unchanged file!?
 -----------------------------------------------------
 
-The files cache (which is used to determine whether |project_name| already
-"knows" / has backed up a file and if so, to skip the file from chunking)
-does intentionally *not* contain files that:
+The files cache is used to determine whether |project_name| already
+"knows" / has backed up a file and if so, to skip the file from
+chunking. It does intentionally *not* contain files that:
 
 - have >= 10 as "entry age" (|project_name| has not seen this file for a while)
 - have a modification time (mtime) same as the newest mtime in the created
@@ -191,6 +193,10 @@ will often be the same and already stored in the repo (except in the above
 mentioned rare condition), it will just re-use them as usual and not store new
 data chunks.
 
+Since only the files cache is used in the display of files status,
+those files are reported as being added when, really, chunks are
+already used.
+
 Why was Borg forked from Attic?
 -------------------------------
 

+ 1 - 1
docs/usage.rst

@@ -444,7 +444,7 @@ A uppercase character represents the status of a regular file relative to the
 is not used). Metadata is stored in any case and for 'A' and 'M' also new data
 chunks are stored. For 'U' all data chunks refer to already existing chunks.
 
-- 'A' = regular file, added
+- 'A' = regular file, added (see also :ref:`a_status_oddity` in the FAQ)
 - 'M' = regular file, modified
 - 'U' = regular file, unchanged
 - 'E' = regular file, an error happened while accessing/reading *this* file