From 5beaa5bd025e27e1981607ffece36106d6027418 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 16 Aug 2017 01:52:33 +0200 Subject: [PATCH] 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. --- borg/cache.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/borg/cache.py b/borg/cache.py index d69614a57..80e57d321 100644 --- a/borg/cache.py +++ b/borg/cache.py @@ -208,10 +208,16 @@ Chunk index: {0.total_unique_chunks:20d} {0.total_chunks:20d}""" if not data: break u.feed(data) - for path_hash, item in u: - item[0] += 1 - # in the end, this takes about 240 Bytes per file - self.files[path_hash] = msgpack.packb(item) + try: + for path_hash, item in u: + item[0] += 1 + # in the end, this takes about 240 Bytes per file + self.files[path_hash] = msgpack.packb(item) + 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