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