浏览代码

Merge pull request #2945 from ThomasWaldmann/workaround-files-cache-corruption-1.1

ignore corrupt files cache, fixes #2939
enkore 7 年之前
父节点
当前提交
1a05e8f446
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      src/borg/cache.py

+ 10 - 4
src/borg/cache.py

@@ -503,10 +503,16 @@ class LocalCache(CacheStatsMixin):
                 if not data:
                     break
                 u.feed(data)
-                for path_hash, item in u:
-                    entry = FileCacheEntry(*item)
-                    # in the end, this takes about 240 Bytes per file
-                    self.files[path_hash] = msgpack.packb(entry._replace(age=entry.age + 1))
+                try:
+                    for path_hash, item in u:
+                        entry = FileCacheEntry(*item)
+                        # in the end, this takes about 240 Bytes per file
+                        self.files[path_hash] = msgpack.packb(entry._replace(age=entry.age + 1))
+                except (TypeError, ValueError) as exc:
+                    logger.warning('The files cache seems corrupt, ignoring it. '
+                                   'Expect lower performance. [%s]' % str(exc))
+                    self.files = {}
+                    return
 
     def begin_txn(self):
         # Initialize transaction snapshot