Commit fa6f3501 authored by Łukasz Nowak's avatar Łukasz Nowak

Make buildout redownload in case of having wrong local md5sum.

parent f0d0ef63
......@@ -132,9 +132,14 @@ class Download(object):
pass
if not check_md5sum(cached_path, md5sum):
try:
_, is_temp = self.download(url, md5sum, cached_path)
except ChecksumError:
raise ChecksumError(
'MD5 checksum mismatch for cached download '
'from %r at %r' % (url, cached_path))
except Exception:
pass
self.logger.debug('Using cache file %s' % cached_path)
else:
self.logger.debug('Cache miss; will cache %s as %s' %
......
......@@ -168,11 +168,28 @@ This is a foo text.
If we specify an MD5 checksum for a file that is already in the cache, the
cached copy's checksum will be verified:
>>> download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
>>> download(server_url+'foo.txt', md5('The totally wrong text.').hexdigest())
Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch for cached download
from 'http://localhost/foo.txt' at '/download-cache/foo.txt'
But if MD5 checksum matches remote resource download utility will try to
download it once to match MD5 checksum:
>>> path, is_temp = download(server_url+'foo.txt', md5('The wrong text.').hexdigest())
>>> print path
/download-cache/foo.txt
>>> cat(path)
The wrong text.
Now it is time to write again the correct text and download it for next test:
>>> write(server_data, 'foo.txt', 'This is a foo text.')
>>> path, is_temp = download(server_url+'foo.txt', md5('This is a foo text.').hexdigest())
>>> print path
/download-cache/foo.txt
>>> cat(path)
This is a foo text.
Trying to access another file at a different URL which has the same base name
will result in the cached copy being used:
......
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