Skip to content

Commit 447aa44

Browse files
authored
Remove download_even_if_exists argument to download_and_unzip (#964)
These days this argument really means `install_even_if_directory_exists` (at least since #9300. However by the time we call `download_and_unzip` we have already checked that `is_installed()` is false so we know we want to install for sure. If the installation directory already existed and contained the correct contents we would never get as far as `download_and_unzip`.
1 parent 2c09626 commit 447aa44

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

emsdk.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,19 +1520,12 @@ def build_binaryen_tool(tool):
15201520
return success
15211521

15221522

1523-
def download_and_unzip(zipfile, dest_dir, download_even_if_exists=False,
1524-
filename_prefix='', clobber=True):
1523+
def download_and_unzip(zipfile, dest_dir, filename_prefix='', clobber=True):
15251524
debug_print('download_and_unzip(zipfile=' + zipfile + ', dest_dir=' + dest_dir + ')')
15261525

15271526
url = urljoin(emsdk_packages_url, zipfile)
15281527
download_target = get_download_target(url, zips_subdir, filename_prefix)
15291528

1530-
# If the archive was already downloaded, and the directory it would be
1531-
# unpacked to has contents, assume it's the same contents and skip.
1532-
if not download_even_if_exists and num_files_in_directory(dest_dir) > 0:
1533-
print("The contents of file '" + zipfile + "' already exist in destination '" + dest_dir + "', skipping.")
1534-
return True
1535-
15361529
received_download_target = download_file(url, zips_subdir, not KEEP_DOWNLOADS, filename_prefix)
15371530
if not received_download_target:
15381531
return False
@@ -2002,13 +1995,7 @@ def install_tool(self):
20021995
elif hasattr(self, 'git_branch'):
20031996
success = git_clone_checkout_and_pull(url, self.installation_path(), self.git_branch)
20041997
elif url.endswith(ARCHIVE_SUFFIXES):
2005-
# The 'releases' sdk is doesn't include a verion number in the directory
2006-
# name and instead only one version can be install at the time and each
2007-
# one will clobber the other. This means we always need to extract this
2008-
# archive even when the target directory exists.
2009-
download_even_if_exists = (self.id == 'releases')
2010-
filename_prefix = getattr(self, 'zipfile_prefix', '')
2011-
success = download_and_unzip(url, self.installation_path(), download_even_if_exists=download_even_if_exists, filename_prefix=filename_prefix)
1998+
success = download_and_unzip(url, self.installation_path(), filename_prefix=getattr(self, 'zipfile_prefix', ''))
20121999
else:
20132000
dst_file = download_file(urljoin(emsdk_packages_url, self.download_url()), self.installation_path())
20142001
if dst_file:
@@ -2242,7 +2229,7 @@ def update_emsdk():
22422229
if is_emsdk_sourced_from_github():
22432230
errlog('You seem to have bootstrapped Emscripten SDK by cloning from GitHub. In this case, use "git pull" instead of "emsdk update" to update emsdk. (Not doing that automatically in case you have local changes)')
22442231
sys.exit(1)
2245-
if not download_and_unzip(emsdk_zip_download_url, emsdk_path(), download_even_if_exists=True, clobber=False):
2232+
if not download_and_unzip(emsdk_zip_download_url, emsdk_path(), clobber=False):
22462233
sys.exit(1)
22472234

22482235

0 commit comments

Comments
 (0)