From f22715b6da9d6c53ab4a7b1354316887a331c54e Mon Sep 17 00:00:00 2001 From: Tadeusz Dudkiewicz Date: Fri, 1 Mar 2019 18:53:04 +0100 Subject: [PATCH] (no-ticket) Fix some things not working with remote filetracker Committer's note: I'm pretty sure the Tadeusz is the author of those changes, so I set him as author, but I found the changes uncommitted, so I'm not 100% sure it's his. -- Wojciech Dubiel Change-Id: I70a51c2e1212cda3e206c0d86f578bdb6c379b86 --- oioioi/confirmations/utils.py | 8 ++++---- oioioi/mailsubmit/utils.py | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) 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