Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yusei Tahara
slapos.buildout
Commits
f04cb8a3
Commit
f04cb8a3
authored
Apr 19, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make buildout redownload in case of having wrong local md5sum.
parent
15534523
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
src/zc/buildout/download.py
src/zc/buildout/download.py
+8
-3
src/zc/buildout/download.txt
src/zc/buildout/download.txt
+18
-1
No files found.
src/zc/buildout/download.py
View file @
f04cb8a3
...
@@ -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
):
raise
ChecksumError
(
try
:
'MD5 checksum mismatch for cached download '
_
,
is_temp
=
self
.
download
(
url
,
md5sum
,
cached_path
)
'from %r at %r'
%
(
url
,
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
)
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'
%
...
...
src/zc/buildout/download.txt
View file @
f04cb8a3
...
@@ -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:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment