Upfront third_party deletion on re-download.
Change-Id: I196f6468ef57e192c8382ae246c73d2c40be3857
diff --git a/tools/utils.py b/tools/utils.py
index 12c441d..d85fa54 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -352,6 +352,13 @@
def EnsureDepFromGoogleCloudStorage(dep, tgz, sha1, msg):
if (not os.path.exists(dep) or not os.path.exists(tgz) or
os.path.getmtime(tgz) < os.path.getmtime(sha1)):
+ if os.path.exists(dep):
+ if os.path.isdir(dep):
+ shutil.rmtree(dep)
+ else:
+ os.remove(dep)
+ if os.path.exists(tgz):
+ os.remove(tgz)
DownloadFromGoogleCloudStorage(sha1)
# Update the mtime of the tar file to make sure we do not run again unless
# there is an update.