summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-09-28 11:27:24 -0400
committerMike Frysinger <vapier@google.com>2021-09-28 16:06:50 +0000
commit9d96f58f5fcec101c612e61c3e2526ca071d89ea (patch)
tree63bc9e73e3b7d74a2cf5352239bf4f2e9695b507 /git_config.py
parent7a1e7e772f3bbc67660e824c98f527b5f608ac24 (diff)
downloadgit-repo-9d96f58f5fcec101c612e61c3e2526ca071d89ea.tar.gz
make file removal a bit more robust
Some of the file removal calls are subject to race conditions (if something else deletes the file), so extend our remove API to have an option to ignore ENOENT errors. Then update a bunch of random call sites to use this new functionality. Change-Id: I31a9090e135452033135337a202a4fc2dbf8b63c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319195 Reviewed-by: Sean McAllister <smcallis@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/git_config.py b/git_config.py
index 778e81a4..bc70d160 100644
--- a/git_config.py
+++ b/git_config.py
@@ -352,8 +352,8 @@ class GitConfig(object):
352 Trace(': parsing %s', self.file) 352 Trace(': parsing %s', self.file)
353 with open(self._json) as fd: 353 with open(self._json) as fd:
354 return json.load(fd) 354 return json.load(fd)
355 except (IOError, ValueError): 355 except (IOError, ValueErrorl):
356 platform_utils.remove(self._json) 356 platform_utils.remove(self._json, missing_ok=True)
357 return None 357 return None
358 358
359 def _SaveJson(self, cache): 359 def _SaveJson(self, cache):
@@ -361,8 +361,7 @@ class GitConfig(object):
361 with open(self._json, 'w') as fd: 361 with open(self._json, 'w') as fd:
362 json.dump(cache, fd, indent=2) 362 json.dump(cache, fd, indent=2)
363 except (IOError, TypeError): 363 except (IOError, TypeError):
364 if os.path.exists(self._json): 364 platform_utils.remove(self._json, missing_ok=True)
365 platform_utils.remove(self._json)
366 365
367 def _ReadGit(self): 366 def _ReadGit(self):
368 """ 367 """