Delete temporary downloaded installer zip files after installation of a tool finishes successfully. Closes https://github.com/kripken/emscripten/issues/1699 .
This commit is contained in:
22
emsdk
22
emsdk
@@ -50,6 +50,13 @@ def file_to_lf(filename):
|
|||||||
text = text.replace('\r\n', '\n')
|
text = text.replace('\r\n', '\n')
|
||||||
open(filename, 'wb').write(text)
|
open(filename, 'wb').write(text)
|
||||||
|
|
||||||
|
# Removes a single file, suppressing exceptions on failure.
|
||||||
|
def rmfile(filename):
|
||||||
|
try:
|
||||||
|
os.remove(filename)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def fix_lineendings(filename):
|
def fix_lineendings(filename):
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
file_to_crlf(filename)
|
file_to_crlf(filename)
|
||||||
@@ -498,6 +505,8 @@ class Tool:
|
|||||||
success = tool.install()
|
success = tool.install()
|
||||||
if not success:
|
if not success:
|
||||||
return False
|
return False
|
||||||
|
print "Done."
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
url = self.download_url()
|
url = self.download_url()
|
||||||
if hasattr(self, 'git_branch'):
|
if hasattr(self, 'git_branch'):
|
||||||
@@ -515,11 +524,20 @@ class Tool:
|
|||||||
return False
|
return False
|
||||||
print "Done."
|
print "Done."
|
||||||
|
|
||||||
# Sanity check that the installation succeeded.
|
# Sanity check that the installation succeeded, and if so, remove unneeded leftover installation files.
|
||||||
if not self.is_installed():
|
if self.is_installed():
|
||||||
|
self.cleanup_temp_install_files()
|
||||||
|
else:
|
||||||
print "Warning: The installation of '" + str(self) + "' seems to have failed, but no error was detected. Either something went wrong with the installation, or this may indicate an internal emsdk error."
|
print "Warning: The installation of '" + str(self) + "' seems to have failed, but no error was detected. Either something went wrong with the installation, or this may indicate an internal emsdk error."
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def cleanup_temp_install_files(self):
|
||||||
|
url = self.download_url()
|
||||||
|
if url.endswith('zip') or url.endswith('.tar') or url.endswith('.gz'):
|
||||||
|
file_name = url.split('/')[-1]
|
||||||
|
tempzipfile = os.path.join('zips/', file_name)
|
||||||
|
rmfile(tempzipfile)
|
||||||
|
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
if not self.is_installed():
|
if not self.is_installed():
|
||||||
print "Tool '" + str(self) + "' was not installed. No need to uninstall."
|
print "Tool '" + str(self) + "' was not installed. No need to uninstall."
|
||||||
|
|||||||
Reference in New Issue
Block a user