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):
async with ClientSession() as client:
res = await client.get(url, ssl=get_ssl_context())
if res.status == 200:
data = BytesIO(await res.read())
remoteHash = sha256(data.getbuffer()).hexdigest()
if binHash == remoteHash:
data.seek(0)
with open(path, 'wb') as f:
f.write(data.getbuffer())
rv = True
if res.status == 200:
logger.debug("Download attempt of URL: " + url)
data = await res.read()
remoteHash = sha256(data).hexdigest()
if binHash == remoteHash:
with open(path, 'wb') as f:
f.write(data)
rv = True
else:
raise Exception(f"Fatal Error: Hash Mismatch for remote binary {path}@{url}")
else:
raise Exception(f"Fatal Error: Hash Mismatch for remote binary {path}@{url}")
else:
rv = False
except:
rv = False
except Exception as e:
logger.error("Error during download" + str(e))
rv = False
return rv