Permalink
Browse files

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>
  • Loading branch information...
Ulrik Sjölin authored and spearce committed Oct 29, 2010
1 parent ec1df9b commit 99482ae58a74e236fb40b65c267163a5690f39e1
Showing with 4 additions and 2 deletions.
  1. +4 −2 git_config.py
View
@@ -257,9 +257,11 @@ def _SavePickle(self, cache):
finally:
fd.close()
except IOError:
- os.remove(self._pickle)
+ if os.path.exists(self._pickle):
+ os.remove(self._pickle)
except cPickle.PickleError:
- os.remove(self._pickle)
+ if os.path.exists(self._pickle):
+ os.remove(self._pickle)
def _ReadGit(self):
"""

0 comments on commit 99482ae

Please sign in to comment.