diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2013-06-29 15:59:08 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2013-06-29 15:59:08 -0700 |
commit | ebc507dc6eaa42be8729f01bcee6cd4d352a9055 (patch) | |
tree | 1a4395d38c84251fa964db19dc770f47ff908ed5 /lib | |
parent | 7a67cc1675f9db5552dbab64cf3e7ef6dbf752f6 (diff) | |
download | spack-ebc507dc6eaa42be8729f01bcee6cd4d352a9055.tar.gz spack-ebc507dc6eaa42be8729f01bcee6cd4d352a9055.tar.bz2 spack-ebc507dc6eaa42be8729f01bcee6cd4d352a9055.tar.xz spack-ebc507dc6eaa42be8729f01bcee6cd4d352a9055.zip |
Clean up half-downloaded tarballs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/stage.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py index 54d5eb7e6a..9145fa5371 100644 --- a/lib/spack/spack/stage.py +++ b/lib/spack/spack/stage.py @@ -155,11 +155,17 @@ class Stage(object): else: tty.msg("Fetching %s" % self.url) - # Run curl but grab the mime type from the http headers - headers = spack.curl('-#', # status bar - '-O', # save file to disk - '-D', '-', # print out HTML headers - '-L', self.url, return_output=True) + try: + # Run curl but grab the mime type from the http headers + headers = spack.curl('-#', # status bar + '-O', # save file to disk + '-D', '-', # print out HTML headers + '-L', self.url, return_output=True) + except: + # clean up archive on failure. + if self.archive_file: + os.remove(self.archive_file) + raise # Check if we somehow got an HTML file rather than the archive we # asked for. We only look at the last content type, to handle |