summaryrefslogtreecommitdiffstats
path: root/platform_utils.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-11-11 04:34:16 -0500
committerMike Frysinger <vapier@google.com>2019-11-12 03:44:33 +0000
commitf4545126197781beb03bb0fd47e7f24ce5af6ca8 (patch)
treec648d5a0a508281c146d1db1f21960f8107342d4 /platform_utils.py
parentb466854bed4348a210fec5870023c1a44cd830b5 (diff)
downloadgit-repo-f4545126197781beb03bb0fd47e7f24ce5af6ca8.tar.gz
sync: make .git init more robust
Hitting Ctrl-C in the middle of this func will leave the .git in a bad state that requires manual recovery. The code tries to catch all exceptions and recover by deleting the incomplete .git dir, but it omits KeyboardInterrupt which Exception misses. We could add that to the recovery path, but we can make this more robust with a different approach: set up everything in .git.tmp/ and only move it to .git/ once we've fully initialized it. Change-Id: I0f5b97f2e19fc39cffc3e5e23993a2da7220f4e3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244733 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'platform_utils.py')
-rw-r--r--platform_utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/platform_utils.py b/platform_utils.py
index 77e8fdf5..6684ebc8 100644
--- a/platform_utils.py
+++ b/platform_utils.py
@@ -241,14 +241,15 @@ def _makelongpath(path):
241 return path 241 return path
242 242
243 243
244def rmtree(path): 244def rmtree(path, ignore_errors=False):
245 """shutil.rmtree(path) wrapper with support for long paths on Windows. 245 """shutil.rmtree(path) wrapper with support for long paths on Windows.
246 246
247 Availability: Unix, Windows.""" 247 Availability: Unix, Windows."""
248 onerror = None
248 if isWindows(): 249 if isWindows():
249 shutil.rmtree(_makelongpath(path), onerror=handle_rmtree_error) 250 path = _makelongpath(path)
250 else: 251 onerror = handle_rmtree_error
251 shutil.rmtree(path) 252 shutil.rmtree(path, ignore_errors=ignore_errors, onerror=onerror)
252 253
253 254
254def handle_rmtree_error(function, path, excinfo): 255def handle_rmtree_error(function, path, excinfo):