mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #717 from yuvipanda/cleanup-retrieve
Don't open file twice when downloading conda
This commit is contained in:
@@ -49,9 +49,12 @@ def download_miniconda_installer(installer_url, sha256sum):
|
||||
of given version, verifies the sha256sum & provides path to it to the `with`
|
||||
block to run.
|
||||
"""
|
||||
with tempfile.NamedTemporaryFile() as f:
|
||||
with open(f.name, 'wb') as f:
|
||||
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.fileno())
|
||||
|
||||
if sha256_file(f.name) != sha256sum:
|
||||
raise Exception('sha256sum hash mismatch! Downloaded file corrupted')
|
||||
|
||||
Reference in New Issue
Block a user