From f4994ae8764d5e9d042c475142ef30a825bc5c1e Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Thu, 2 Jan 2014 15:06:27 +0000 Subject: [PATCH] Don't bail out of the cpplint cache is broken. Instead, try to remove it. BUG=none R=ulan@chromium.org LOG=n Review URL: https://codereview.chromium.org/117823013 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18441 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- tools/presubmit.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/presubmit.py b/tools/presubmit.py index 56eac8e..88f1459 100755 --- a/tools/presubmit.py +++ b/tools/presubmit.py @@ -144,8 +144,8 @@ class FileContentsCache(object): try: sums_file = open(self.sums_file_name, 'r') self.sums = pickle.load(sums_file) - except IOError: - # File might not exist, this is OK. + except: + # Cannot parse pickle for any reason. Not much we can do about it. pass finally: if sums_file: @@ -155,6 +155,14 @@ class FileContentsCache(object): try: sums_file = open(self.sums_file_name, 'w') pickle.dump(self.sums, sums_file) + except: + # Failed to write pickle. Try to clean-up behind us. + if sums_file: + sums_file.close() + try: + os.unlink(self.sums_file_name) + except: + pass finally: sums_file.close() -- 2.7.4