White-space formatting is one of the most incomprehensible decisions...

This commit is contained in:
TrainDoctor
2025-02-08 14:23:07 -08:00
parent 310dd700ac
commit c1dd1c7296
+13 -12
View File
@@ -112,19 +112,20 @@ async def download_remote_binary_to_path(url: str, binHash: str, path: str) -> b
if os.access(os.path.dirname(path), os.W_OK): if os.access(os.path.dirname(path), os.W_OK):
async with ClientSession() as client: async with ClientSession() as client:
res = await client.get(url, ssl=get_ssl_context()) res = await client.get(url, ssl=get_ssl_context())
if res.status == 200: if res.status == 200:
data = BytesIO(await res.read()) logger.debug("Download attempt of URL: " + url)
remoteHash = sha256(data.getbuffer()).hexdigest() data = await res.read()
if binHash == remoteHash: remoteHash = sha256(data).hexdigest()
data.seek(0) if binHash == remoteHash:
with open(path, 'wb') as f: with open(path, 'wb') as f:
f.write(data.getbuffer()) f.write(data)
rv = True rv = True
else:
raise Exception(f"Fatal Error: Hash Mismatch for remote binary {path}@{url}")
else: else:
raise Exception(f"Fatal Error: Hash Mismatch for remote binary {path}@{url}") rv = False
else: except Exception as e:
rv = False logger.error("Error during download" + str(e))
except:
rv = False rv = False
return rv return rv