Don't fail on empty LocalStatus cache files
As reported in https://github.com/spaetz/offlineimap/pull/2, we would fail when files are empty because file.read() would throw attribute errors. Fix this by removing the superfluous read() check and additionally log some warning message. Reported-by: Ralf Schmitt Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
50e78a8d41
commit
8ec6980c96
@ -65,9 +65,11 @@ class LocalStatusFolder(BaseFolder):
|
|||||||
file = open(self.filename, "rt")
|
file = open(self.filename, "rt")
|
||||||
self.messagelist = {}
|
self.messagelist = {}
|
||||||
line = file.readline().strip()
|
line = file.readline().strip()
|
||||||
if not line and not line.read():
|
if not line:
|
||||||
# The status file is empty - should not have happened,
|
# The status file is empty - should not have happened,
|
||||||
# but somehow did.
|
# but somehow did.
|
||||||
|
errstr = "Cache file '%s' is empty. Closing..." % self.filename
|
||||||
|
self.ui.warn(errstr)
|
||||||
file.close()
|
file.close()
|
||||||
return
|
return
|
||||||
assert(line == magicline)
|
assert(line == magicline)
|
||||||
|
Loading…
Reference in New Issue
Block a user