Skip to content
Snippets Groups Projects
Commit 7906228e authored by Becker, Benjamin's avatar Becker, Benjamin
Browse files

Merge pull request #57 in TPSH/ckanext-odsh from test-hash to master

* commit '0dda2def':
  resets file pointer to 0
  adds debug messages to _raise_validation_error_if_hash_values_differ
parents d208079e 0dda2def
Branches
Tags v1.0
No related merge requests found
......@@ -29,6 +29,7 @@ def _raise_validation_error_if_virus_found(filename, upload_file):
def calculate_hash(upload_file):
upload_file.seek(0)
hash_md5 = hashlib.md5()
for chunk in iter(lambda: upload_file.read(4096), b""):
hash_md5.update(chunk)
......@@ -41,6 +42,8 @@ def _raise_validation_error_if_hash_values_differ(upload_file, resource):
if hash_from_resource:
hash_from_calculation = calculate_hash(upload_file)
if not hash_from_calculation == hash_from_resource:
log.debug('hash from calculation: {}'.format(hash_from_calculation))
log.debug('hash from resource: {}'.format(hash_from_resource))
raise logic.ValidationError({'upload': ['Berechneter Hash und mitgelieferter Hash sind unterschiedlich']})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment