From b1ff307674fb4dde80d8b63bdcdb3553561e9ae3 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Wed, 4 May 2011 19:44:01 +0200 Subject: [PATCH] Output more detailed error on corrupt LocalStatus When our LocalStatus cache is corrupt, ie e.g. it contains lines not in the form number:number, we would previously just raise a ValueError stating things like "too many values". In case we encounter clearly corrupt LocalStatus cache entries, clearly raise an exception stating the filename and the line, so that people can attempt to repair it. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/folder/LocalStatus.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/offlineimap/folder/LocalStatus.py b/offlineimap/folder/LocalStatus.py index 50a0f55..3a0a16d 100644 --- a/offlineimap/folder/LocalStatus.py +++ b/offlineimap/folder/LocalStatus.py @@ -77,8 +77,13 @@ class LocalStatusFolder(BaseFolder): assert(line == magicline) for line in file.xreadlines(): line = line.strip() - uid, flags = line.split(':') - uid = long(uid) + try: + uid, flags = line.split(':') + uid = long(uid) + except ValueError, e: + errstr = "Corrupt line '%s' in cache file '%s'" % (line, self.filename) + self.ui.warn(errstr) + raise ValueError(errstr) flags = [x for x in flags] self.messagelist[uid] = {'uid': uid, 'flags': flags} file.close()