mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 12:11:33 -06:00
SC2: verify downloaded data is a zipfile
This commit is contained in:
@@ -10,6 +10,8 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import typing
|
import typing
|
||||||
import queue
|
import queue
|
||||||
|
import zipfile
|
||||||
|
import io
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# CommonClient import first to trigger ModuleUpdater
|
# CommonClient import first to trigger ModuleUpdater
|
||||||
@@ -137,7 +139,6 @@ class StarcraftClientProcessor(ClientCommandProcessor):
|
|||||||
|
|
||||||
if tempzip != '':
|
if tempzip != '':
|
||||||
try:
|
try:
|
||||||
import zipfile
|
|
||||||
zipfile.ZipFile(tempzip).extractall(path=os.environ["SC2PATH"])
|
zipfile.ZipFile(tempzip).extractall(path=os.environ["SC2PATH"])
|
||||||
sc2_logger.info(f"Download complete. Version {version} installed.")
|
sc2_logger.info(f"Download complete. Version {version} installed.")
|
||||||
with open(os.environ["SC2PATH"]+"ArchipelagoSC2Version.txt", "w") as f:
|
with open(os.environ["SC2PATH"]+"ArchipelagoSC2Version.txt", "w") as f:
|
||||||
@@ -1008,7 +1009,7 @@ def download_latest_release_zip(owner: str, repo: str, current_version: str = No
|
|||||||
download_url = r1.json()["assets"][0]["browser_download_url"]
|
download_url = r1.json()["assets"][0]["browser_download_url"]
|
||||||
|
|
||||||
r2 = requests.get(download_url, headers=headers)
|
r2 = requests.get(download_url, headers=headers)
|
||||||
if r2.status_code == 200:
|
if r2.status_code == 200 and zipfile.is_zipfile(io.BytesIO(r2.content)):
|
||||||
with open(f"{repo}.zip", "wb") as fh:
|
with open(f"{repo}.zip", "wb") as fh:
|
||||||
fh.write(r2.content)
|
fh.write(r2.content)
|
||||||
sc2_logger.info(f"Successfully downloaded {repo}.zip.")
|
sc2_logger.info(f"Successfully downloaded {repo}.zip.")
|
||||||
|
Reference in New Issue
Block a user