Skip to content

Commit 7951c23

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Clean up emscripten state when updating
We should clear the old version once we try to update the to a new one else old files may linger Bug: none Change-Id: Ieb15ab58b454bff877431499cefbf5bb6e619a02 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6243826 Auto-Submit: Nikolay Vitkov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Liviu Rau <[email protected]>
1 parent cff61d4 commit 7951c23

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/deps/download_emscripten.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import argparse
1212
import os
1313
import platform
14+
import shutil
1415
import sys
1516
import tarfile
1617
import urllib.request
@@ -21,10 +22,12 @@
2122
DOWNLOAD_URL = "https://storage.googleapis.com/webassembly/emscripten-releases-builds/%s/%s/wasm-binaries%s.%s"
2223

2324

25+
# Returns None when files was not found
26+
# Return boolean if file found depending on version is the same
2427
def check_stamp_file(options, url):
2528
file_name = os.path.join(options.dest, STAMP_FILE)
2629
if not os.path.isfile(file_name):
27-
return False
30+
return None
2831
with open(file_name) as f:
2932
return url == f.read().strip()
3033

@@ -64,8 +67,14 @@ def script_main(args):
6467

6568
url = DOWNLOAD_URL % (os_name, options.tag, arch_suffix, file_extension)
6669

67-
if check_stamp_file(options, url):
70+
build_revision_same = check_stamp_file(options, url)
71+
if build_revision_same:
6872
return 0
73+
elif build_revision_same is False:
74+
try:
75+
shutil.rmtree(os.path.join(options.dest, 'install'))
76+
except Exception as e:
77+
sys.stderr.write('Error while remove old version: {e}'.format(e=e))
6978

7079
try:
7180
filename, _ = urllib.request.urlretrieve(url)

0 commit comments

Comments
 (0)