Remove the old cache dir before moving the bootstrapped cache dir into the real location

Seems like some combination of things (bad cache dir, shallow checkout, etc) causes
git cache to not clean up properly before trying to move new directory A into
already existing directory B.

So the logic is all there to detect that the cache is invalid, its just not
being cleaned up properly during shallow checkouts.

BUG=406864
TBR=iannucci

Review URL: https://codereview.chromium.org/499123002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@291587 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cache.py b/git_cache.py
index bfdef80..2125253 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -416,6 +416,8 @@
     finally:
       if tempdir:
         try:
+          if os.path.exists(self.mirror_path):
+            gclient_utils.rmtree(self.mirror_path)
           os.rename(tempdir, self.mirror_path)
         except OSError as e:
           # This is somehow racy on Windows.