git_cache: remove the mirror_path if it exists in an incomplete state.
Bug: 958286
Change-Id: If8351dfc0790e1db5867c103139a067c651fca3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1590500
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cache.py b/git_cache.py
index 5bc15d7..44e59a3 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -13,11 +13,11 @@
import optparse
import os
import re
+import subprocess
+import sys
import tempfile
import threading
import time
-import subprocess
-import sys
try:
import urlparse
@@ -495,6 +495,11 @@
# Re-bootstrapping an existing mirror; preserve existing fetch spec.
self._preserve_fetchspec()
else:
+ if os.path.exists(self.mirror_path):
+ # If the mirror path exists but self.exists() returns false, we're
+ # in an unexpected state. Nuke the previous mirror directory and
+ # start fresh.
+ gclient_utils.rmtree(self.mirror_path)
os.mkdir(self.mirror_path)
bootstrapped = (not depth and bootstrap and
@@ -864,4 +869,4 @@
sys.exit(main(sys.argv[1:]))
except KeyboardInterrupt:
sys.stderr.write('interrupted\n')
- sys.exit(1)
\ No newline at end of file
+ sys.exit(1)