Commit e0d325c2 authored by Jim Fulton's avatar Jim Fulton

Author: Alexandru Plugaru <alexandru.plugaru@gmail.com>

Date:   Mon Mar 14 18:18:04 2011 +0000
Fixes #566167

Cherry-picked from svntrunk
parent e6245154
......@@ -175,16 +175,19 @@ class Download(object):
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:
tmp_path, headers = urllib.urlretrieve(url, tmp_path)
if not check_md5sum(tmp_path, md5sum):
raise ChecksumError(
'MD5 checksum mismatch downloading %r' % url)
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