Browse Source

borg check: check file size consistency

Thomas Waldmann 8 years ago
parent
commit
adc4da280d
2 changed files with 10 additions and 1 deletions
  1. 7 0
      src/borg/archive.py
  2. 3 1
      src/borg/item.pyx

+ 7 - 0
src/borg/archive.py

@@ -1306,6 +1306,13 @@ class ArchiveChecker:
                 logger.info('{}: Completely healed previously damaged file!'.format(item.path))
                 del item.chunks_healthy
             item.chunks = chunk_list
+            if 'size' in item:
+                item_size = item.size
+                item_chunks_size = item.get_size(compressed=False, from_chunks=True)
+                if item_size != item_chunks_size:
+                    # just warn, but keep the inconsistency, so that borg extract can warn about it.
+                    logger.warning('{}: size inconsistency detected: size {}, chunks size {}'.format(
+                                   item.path, item_size, item_chunks_size))
 
         def robust_iterator(archive):
             """Iterates through all archive items

+ 3 - 1
src/borg/item.pyx

@@ -176,7 +176,7 @@ class Item(PropDict):
 
     part = PropDict._make_property('part', int)
 
-    def get_size(self, hardlink_masters=None, memorize=False, compressed=False):
+    def get_size(self, hardlink_masters=None, memorize=False, compressed=False, from_chunks=False):
         """
         Determine the (uncompressed or compressed) size of this item.
 
@@ -187,6 +187,8 @@ class Item(PropDict):
         """
         attr = 'csize' if compressed else 'size'
         try:
+            if from_chunks:
+                raise AttributeError
             size = getattr(self, attr)
         except AttributeError:
             # no precomputed (c)size value available, compute it: