Skip to content

Commit

Permalink
dependency_script - only verify checksum of new downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjc committed Aug 17, 2016
1 parent f88f055 commit 84f498b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions planemo/shed2tap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,14 @@ def _cache_download(url, filename, sha256sum=None):
# Most likely server is down, could be bad URL in XML action:
raise RuntimeError("Unable to download %s" % url)

if sha256sum:
# TODO - log this nicely...
sys.stderr.write("Verifying checksum for %s\n" % filename)
filehash = subprocess.check_output(['shasum', '-a', '256', local])[0:64].strip()
if filehash != sha256sum:
raise RuntimeError("Checksum failure for %s, got %r but wanted %r" % (local, filehash, sha256sum))
# Verifying the checksum is slow, only do this on a fresh
# download. Assume locally cached files are already OK.
if sha256sum:
# TODO - log this nicely...
sys.stderr.write("Verifying checksum for %s\n" % filename)
filehash = subprocess.check_output(['shasum', '-a', '256', local])[0:64].strip()
if filehash != sha256sum:
raise RuntimeError("Checksum failure for %s, got %r but wanted %r" % (local, filehash, sha256sum))

return local

Expand Down

0 comments on commit 84f498b

Please sign in to comment.