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

Make buildout redownload in case of having wrong local md5sum.

parent 15534523
...@@ -132,9 +132,14 @@ class Download(object): ...@@ -132,9 +132,14 @@ class Download(object):
pass pass
if not check_md5sum(cached_path, md5sum): if not check_md5sum(cached_path, md5sum):
try:
_, is_temp = self.download(url, md5sum, cached_path)
except ChecksumError:
raise ChecksumError( raise ChecksumError(
'MD5 checksum mismatch for cached download ' 'MD5 checksum mismatch for cached download '
'from %r at %r' % (url, cached_path)) 'from %r at %r' % (url, cached_path))
except Exception:
pass
self.logger.debug('Using cache file %s' % cached_path) self.logger.debug('Using cache file %s' % cached_path)
else: else:
self.logger.debug('Cache miss; will cache %s as %s' % self.logger.debug('Cache miss; will cache %s as %s' %
......
...@@ -168,11 +168,28 @@ This is a foo text. ...@@ -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 If we specify an MD5 checksum for a file that is already in the cache, the
cached copy's checksum will be verified: 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): Traceback (most recent call last):
ChecksumError: MD5 checksum mismatch for cached download ChecksumError: MD5 checksum mismatch for cached download
from 'http://localhost/foo.txt' at '/download-cache/foo.txt' 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 Trying to access another file at a different URL which has the same base name
will result in the cached copy being used: 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