Apply suggestions from code review

This commit is contained in:
Erik Sundell
2021-10-19 13:47:11 +02:00
committed by GitHub
parent 6d6ec61102
commit de146690ad

View File

@@ -51,8 +51,10 @@ def download_miniconda_installer(installer_url, sha256sum):
"""
with tempfile.NamedTemporaryFile('wb') as f:
f.write(requests.get(installer_url).content)
# Remain in the NamedTemporaryFile context, but flush changes, see:
# https://docs.python.org/3/library/os.html#os.fsync
f.flush()
os.fsync(f)
os.fsync(f.fileno())
if sha256_file(f.name) != sha256sum:
raise Exception('sha256sum hash mismatch! Downloaded file corrupted')