Don't force re-download of all archives during install (#411)

Only do this for the new `emscripten-releases`.   These all install
the the same directory so we can't use the presence of the directory
to know if we have already installed them.
This commit is contained in:
Sam Clegg
2019-12-11 16:55:06 -06:00
committed by GitHub
parent 9c60ff91d1
commit 322c7aa727
2 changed files with 13 additions and 7 deletions

View File

@@ -1241,7 +1241,7 @@ def download_and_unzip(zipfile, dest_dir, download_even_if_exists=False,
# If the archive was already downloaded, and the directory it would be
# unpacked to has contents, assume it's the same contents and skip.
if not download_even_if_exists and os.path.exists(download_target) and num_files_in_directory(dest_dir) > 0:
if not download_even_if_exists and num_files_in_directory(dest_dir) > 0:
print("The contents of file '" + zipfile + "' already exist in destination '" + dest_dir + "', skipping.")
return True
# Otherwise, if the archive must be downloaded, always write into the
@@ -1724,11 +1724,11 @@ class Tool(object):
elif url.endswith(ARCHIVE_SUFFIXES):
# TODO: explain the vs-tool special-casing
download_even_if_exists = (self.id == 'vs-tool')
# if we are downloading a zip, we will unpack and delete it after immediately anyhow,
# so there is no need to look for an existing one (which may have been left behind
# due to an error in the past)
if url.endswith(ARCHIVE_SUFFIXES):
download_even_if_exists = True
# The 'releases' sdk is doesn't include a verion number in the directory
# name and instead only one version can be install at the time and each
# one will clobber the other. This means we always need to extract this
# archive even when the target directory exists.
download_even_if_exists = (self.id == 'releases')
filename_prefix = getattr(self, 'zipfile_prefix', '')
success = download_and_unzip(url, self.installation_path(), download_even_if_exists=download_even_if_exists, filename_prefix=filename_prefix)
else:

View File

@@ -135,6 +135,12 @@ print('clear cache')
check_call(upstream_emcc + ' --clear-cache')
assert not os.path.exists(LIBC)
# Test the normal tools like node don't re-download on re-install
print('another install must re-download')
checked_call_with_output(emsdk + ' uninstall node-12.9.1-64bit')
checked_call_with_output(emsdk + ' install node-12.9.1-64bit', expected='Downloading:', unexpected='already exist in destination')
checked_call_with_output(emsdk + ' install node-12.9.1-64bit', unexpected='Downloading:', expected='already exist in destination')
print('test tot-upstream')
run_emsdk('install tot-upstream')
assert not os.path.exists(LIBC)
@@ -157,7 +163,7 @@ run_emsdk('activate sdk-1.38.31-64bit')
print('test specific release (new, short name)')
run_emsdk('install 1.38.33')
print('another install must re-download')
checked_call_with_output(emsdk + ' install 1.38.33', expected='Downloading:', unexpected='already exist in destination')
checked_call_with_output(emsdk + ' install 1.38.33', expected='Downloading:')
run_emsdk('activate 1.38.33')
assert 'upstream' not in open(os.path.expanduser('~/.emscripten')).read()
assert 'fastcomp' in open(os.path.expanduser('~/.emscripten')).read()