Commit e5d1acfc authored by alex_plugaru's avatar alex_plugaru

Fixes #566167

git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@120917 62d5b8a3-27da-0310-9561-8e5933582275
parent 8f1a8c9a
......@@ -174,17 +174,20 @@ class Download(object):
self.logger.info('Downloading %s' % url)
urllib._urlopener = url_opener
handle, tmp_path = tempfile.mkstemp(prefix='buildout-')
try:
try:
tmp_path, headers = urllib.urlretrieve(url, tmp_path)
if not check_md5sum(tmp_path, md5sum):
raise ChecksumError(
'MD5 checksum mismatch downloading %r' % url)
finally:
os.close(handle)
except:
except IOError, e:
os.remove(tmp_path)
raise zc.buildout.UserError("Error downloading extends for URL "
"%s: %r" % (url, e[1:3]))
except Exception, e:
os.remove(tmp_path)
raise
finally:
os.close(handle)
if path:
shutil.move(tmp_path, path)
......
......@@ -254,6 +254,13 @@ ChecksumError: MD5 checksum mismatch downloading 'http://localhost/foo.txt'
>>> remove(path)
If the file is completely missing it should notify the user of the error:
>>> download(server_url+'bar.txt')
Traceback (most recent call last):
UserError: Error downloading extends for URL http://localhost/bar.txt: (404, 'Not Found')
>>> ls(cache)
Finally, let's see what happens if the download cache to be used doesn't exist
as a directory in the file system yet:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment