소스 검색

ignore corrupt files cache, fixes #2939

ignore the files cache when corrupt and emit a warning message
so the users notices that there is a problem.

(cherry picked from commit 5beaa5bd025e27e1981607ffece36106d6027418)
Thomas Waldmann 7 년 전
부모
커밋
4eadb59c10
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:
                 if not data:
                     break
                     break
                 u.feed(data)
                 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):
     def begin_txn(self):
         # Initialize transaction snapshot
         # Initialize transaction snapshot