From 322c7aa727f060443bad7d2a012add141da7ec1c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 11 Dec 2019 16:55:06 -0600 Subject: [PATCH] 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. --- emsdk.py | 12 ++++++------ test.py | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/emsdk.py b/emsdk.py index d294e58..c603e5e 100755 --- a/emsdk.py +++ b/emsdk.py @@ -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: diff --git a/test.py b/test.py index e3cd3a0..c1ed8c4 100755 --- a/test.py +++ b/test.py @@ -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()