From 99214033275234793ecde098f36e7c30e66382c7 Mon Sep 17 00:00:00 2001 From: YuviPanda Date: Tue, 19 Oct 2021 14:05:36 +0530 Subject: [PATCH] Don't open file twice when downloading conda Unnecessary, and could also possibly cause races - see https://github.com/jupyterhub/the-littlest-jupyterhub/pull/710#issuecomment-946165463 --- tljh/conda.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tljh/conda.py b/tljh/conda.py index 3fa8a87..ee8568c 100644 --- a/tljh/conda.py +++ b/tljh/conda.py @@ -49,9 +49,8 @@ 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: - f.write(requests.get(installer_url).content) + with tempfile.NamedTemporaryFile('wb') as f: + f.write(requests.get(installer_url).content) if sha256_file(f.name) != sha256sum: raise Exception('sha256sum hash mismatch! Downloaded file corrupted')