fix: handle hdiffpatch downloading for each architecture
This commit is contained in:
parent
9569019fcf
commit
f4e09a7aad
@ -8,6 +8,7 @@ from vollerei.exceptions.game import GameError
|
|||||||
from vollerei.hsr import Game, Patcher
|
from vollerei.hsr import Game, Patcher
|
||||||
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
||||||
from vollerei.hsr.patcher import PatchType
|
from vollerei.hsr.patcher import PatchType
|
||||||
|
from vollerei import paths
|
||||||
|
|
||||||
patcher = Patcher()
|
patcher = Patcher()
|
||||||
|
|
||||||
@ -49,6 +50,8 @@ def callback(
|
|||||||
channel = GameChannel[channel.capitalize()]
|
channel = GameChannel[channel.capitalize()]
|
||||||
elif isinstance(channel, int):
|
elif isinstance(channel, int):
|
||||||
channel = GameChannel(channel)
|
channel = GameChannel(channel)
|
||||||
|
if temporary_path:
|
||||||
|
paths.set_base_path(temporary_path)
|
||||||
State.game: Game = Game(game_path, temporary_path)
|
State.game: Game = Game(game_path, temporary_path)
|
||||||
if channel:
|
if channel:
|
||||||
State.game.channel_override = channel
|
State.game.channel_override = channel
|
||||||
|
@ -20,7 +20,7 @@ class Paths:
|
|||||||
def set_base_path(path: PathLike):
|
def set_base_path(path: PathLike):
|
||||||
path = Path(path)
|
path = Path(path)
|
||||||
Paths.base_paths = path
|
Paths.base_paths = path
|
||||||
Paths.cache_path = Paths.base_paths.joinpath("Cache")
|
Paths.cache_path = Paths.base_paths.joinpath("cache")
|
||||||
Paths.data_path = Paths.base_paths
|
Paths.data_path = Paths.base_paths
|
||||||
Paths.tools_data_path = Paths.data_path.joinpath("tools")
|
Paths.tools_data_path = Paths.data_path.joinpath("tools")
|
||||||
Paths.tools_cache_path = Paths.cache_path.joinpath("tools")
|
Paths.tools_cache_path = Paths.cache_path.joinpath("tools")
|
||||||
|
@ -26,22 +26,33 @@ class HDiffPatch:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_platform_arch():
|
def _get_platform_arch():
|
||||||
|
processor = platform.machine()
|
||||||
match platform.system():
|
match platform.system():
|
||||||
case "Windows":
|
case "Windows":
|
||||||
match platform.architecture()[0]:
|
match processor:
|
||||||
case "32bit":
|
case "i386":
|
||||||
return "windows32"
|
return "windows32"
|
||||||
case "64bit":
|
case "x86_64":
|
||||||
return "windows64"
|
return "windows64"
|
||||||
|
case "arm":
|
||||||
|
return "windows_arm32"
|
||||||
|
case "arm64":
|
||||||
|
return "windows_arm64"
|
||||||
case "Linux":
|
case "Linux":
|
||||||
match platform.architecture()[0]:
|
match processor:
|
||||||
case "32bit":
|
case "i386":
|
||||||
return "linux32"
|
return "linux32"
|
||||||
case "64bit":
|
case "x86_64":
|
||||||
return "linux64"
|
return "linux64"
|
||||||
|
case "arm":
|
||||||
|
return "linux_arm32"
|
||||||
|
case "arm64":
|
||||||
|
return "linux_arm64"
|
||||||
case "Darwin":
|
case "Darwin":
|
||||||
return "macos"
|
return "macos"
|
||||||
|
|
||||||
|
# TODO: Add support for Android & other architectures
|
||||||
|
|
||||||
# Rip BSD they need to use Linux compatibility layer to run this
|
# Rip BSD they need to use Linux compatibility layer to run this
|
||||||
# (or use Wine if they prefer that)
|
# (or use Wine if they prefer that)
|
||||||
raise PlatformNotSupportedError(
|
raise PlatformNotSupportedError(
|
||||||
@ -88,16 +99,11 @@ class HDiffPatch:
|
|||||||
params={"Headers": "Accept: application/vnd.github.v3+json"},
|
params={"Headers": "Accept: application/vnd.github.v3+json"},
|
||||||
)
|
)
|
||||||
rsp.raise_for_status()
|
rsp.raise_for_status()
|
||||||
|
archive_processor = self._get_platform_arch()
|
||||||
for asset in rsp.json()["assets"]:
|
for asset in rsp.json()["assets"]:
|
||||||
if not asset["name"].endswith(".zip"):
|
if not asset["name"].endswith(".zip"):
|
||||||
continue
|
continue
|
||||||
if "linux" in asset["name"]:
|
if archive_processor not in asset["name"]:
|
||||||
continue
|
|
||||||
if "windows" in asset["name"]:
|
|
||||||
continue
|
|
||||||
if "macos" in asset["name"]:
|
|
||||||
continue
|
|
||||||
if "android" in asset["name"]:
|
|
||||||
continue
|
continue
|
||||||
return asset
|
return asset
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user