Ignore EOFError when reading a truncated pickle file

If the pickle config file is 0 bytes in length,  we may have
crashed (or been aborted) while writing the file out to disk.
Instead of crashing with a backtrace, just treat the file as
though it wasn't present and load off a `git config` fork.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2009-06-12 09:10:07 -07:00
parent 7b4f43542a
commit 2a3a81b51f

View File

@ -236,6 +236,9 @@ class GitConfig(object):
return cPickle.load(fd)
finally:
fd.close()
except EOFError:
os.remove(self._pickle)
return None
except IOError:
os.remove(self._pickle)
return None