Переглянути джерело

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>
Shawn O. Pearce 16 роки тому
батько
коміт
2a3a81b51f
1 змінених файлів з 3 додано та 0 видалено
  1. 3 0
      git_config.py

+ 3 - 0
git_config.py

@@ -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