diff options
author | Ulrik Sjölin <ulrik.sjolin@sonyericsson.com> | 2010-10-29 08:23:30 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2010-10-29 08:25:04 -0700 |
commit | 99482ae58a74e236fb40b65c267163a5690f39e1 (patch) | |
tree | 634b25fb07a6e37cafb9c0273bf1a3eb7297ac2f | |
parent | ec1df9b7f6310ce5dd9432b727eb9f7bde9f2796 (diff) | |
download | git-repo-99482ae58a74e236fb40b65c267163a5690f39e1.tar.gz |
Only delete corrupt pickle config files if they exist
os.remove() raises OSError if the file being removed doesn't exist.
Check before calling to ensure we don't raise a useless exception
on an already deleted file.
Change-Id: I44c1c7dd97a47fcab8afb6c18fdf179158b6dab7
Signed-off-by: Shawn O. Pearce <sop@google.com>
-rw-r--r-- | git_config.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/git_config.py b/git_config.py index 138470c5..8e3dfb1b 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -257,9 +257,11 @@ class GitConfig(object): | |||
257 | finally: | 257 | finally: |
258 | fd.close() | 258 | fd.close() |
259 | except IOError: | 259 | except IOError: |
260 | os.remove(self._pickle) | 260 | if os.path.exists(self._pickle): |
261 | os.remove(self._pickle) | ||
261 | except cPickle.PickleError: | 262 | except cPickle.PickleError: |
262 | os.remove(self._pickle) | 263 | if os.path.exists(self._pickle): |
264 | os.remove(self._pickle) | ||
263 | 265 | ||
264 | def _ReadGit(self): | 266 | def _ReadGit(self): |
265 | """ | 267 | """ |