aboutsummaryrefslogtreecommitdiff
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)
downloadrepo-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 77e8fdf..6684ebc 100644
--- a/platform_utils.py
+++ b/platform_utils.py
@@ -241,14 +241,15 @@ def _makelongpath(path):
return path
-def rmtree(path):
+def rmtree(path, ignore_errors=False):
"""shutil.rmtree(path) wrapper with support for long paths on Windows.
Availability: Unix, Windows."""
+ onerror = None
if isWindows():
- shutil.rmtree(_makelongpath(path), onerror=handle_rmtree_error)
- else:
- shutil.rmtree(path)
+ path = _makelongpath(path)
+ onerror = handle_rmtree_error
+ shutil.rmtree(path, ignore_errors=ignore_errors, onerror=onerror)
def handle_rmtree_error(function, path, excinfo):