diff --git a/oioioi/confirmations/utils.py b/oioioi/confirmations/utils.py index 078f9e499..df725f772 100644 --- a/oioioi/confirmations/utils.py +++ b/oioioi/confirmations/utils.py @@ -42,10 +42,10 @@ def submission_receipt_proof(submission): ).count() + 1 ) - source_hash = hashlib.sha256() - for chunk in submission.source_file.chunks(): - source_hash.update(chunk) - submission.source_file.seek(0) + with submission.source_file.read_using_cache() as source_file: + source_hash = hashlib.sha256() + for chunk in source_file.chunks(): + source_hash.update(chunk) proof_data = { 'id': submission.id, diff --git a/oioioi/mailsubmit/utils.py b/oioioi/mailsubmit/utils.py index 29b77b7a4..4fc9284e7 100644 --- a/oioioi/mailsubmit/utils.py +++ b/oioioi/mailsubmit/utils.py @@ -74,10 +74,9 @@ def accept_mail_submission(request, mailsubmission): def mail_submission_hashes(mailsubmission): source_hash = hashlib.sha256() - for chunk in mailsubmission.source_file.chunks(): + for chunk in mailsubmission.source_file.read_using_cache().chunks(): source_hash.update(chunk) source_hash = source_hash.hexdigest() - mailsubmission.source_file.seek(0) pi = mailsubmission.problem_instance