From abbf94b21a60f09d2c5d956f4e6aa5c40c75006a Mon Sep 17 00:00:00 2001 From: tretrauit Date: Sat, 17 Jun 2023 09:25:54 +0700 Subject: [PATCH] fix: whatever random thing I throw into this commit To fix bugs ofc --- vollerei/constants.py | 4 ---- vollerei/hsr/constants.py | 3 +++ vollerei/hsr/patcher.py | 15 +++++++++++---- vollerei/paths.py | 30 ++++++++++++++++-------------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/vollerei/constants.py b/vollerei/constants.py index 8ca8973..b711d29 100644 --- a/vollerei/constants.py +++ b/vollerei/constants.py @@ -8,7 +8,3 @@ telemetry_hosts = [ "log-upload.mihoyo.com", "public-data-api.mihoyo.com", ] - -# HSR -astra_repo = "https://notabug.org/mkrsym1/astra" -jadeite_repo = "https://codeberg.org/mkrsym1/jadeite/" diff --git a/vollerei/hsr/constants.py b/vollerei/hsr/constants.py index d8d4f84..49a3713 100644 --- a/vollerei/hsr/constants.py +++ b/vollerei/hsr/constants.py @@ -11,3 +11,6 @@ md5sums = { }, } } +# Patches +astra_repo = "https://notabug.org/mkrsym1/astra" +jadeite_repo = "https://codeberg.org/mkrsym1/jadeite/" diff --git a/vollerei/hsr/patcher.py b/vollerei/hsr/patcher.py index 25f967e..5546575 100644 --- a/vollerei/hsr/patcher.py +++ b/vollerei/hsr/patcher.py @@ -1,4 +1,3 @@ -from pathlib import Path from enum import Enum from shutil import copy2 from distutils.version import StrictVersion @@ -8,7 +7,7 @@ from vollerei.exceptions.patcher import VersionNotSupportedError from vollerei.hsr.launcher.game import Game, GameChannel from vollerei.utils import download_and_extract, Git, Xdelta3 from vollerei.paths import tools_data_path -from vollerei.constants import astra_repo, jadeite_repo +from vollerei.hsr.constants import astra_repo, jadeite_repo class PatchType(Enum): @@ -24,6 +23,10 @@ class PatchType(Enum): class Patcher(PatcherABC): + """ + Patch helper for HSR. + """ + def __init__(self, patch_type: PatchType = PatchType.Jadeite): self._patch_type: PatchType = patch_type self._path = tools_data_path.joinpath("patcher") @@ -45,8 +48,9 @@ class Patcher(PatcherABC): self._git.pull_or_clone(astra_repo, self._astra) def _update_jadeite(self): - file = self._git.get_latest_release_dl(jadeite_repo)[0] - file_version = Path(file).stem[1:] + release_info = self._git.get_latest_release(jadeite_repo) + file = self._git.get_latest_release_dl(release_info)[0] + file_version = release_info["tag_name"][1:] # Remove "v" prefix current_version = None if self._jadeite.joinpath("version").exists(): with open(self._jadeite.joinpath("version"), "r") as f: @@ -121,3 +125,6 @@ class Patcher(PatcherABC): self._patch_astra(game) case PatchType.Jadeite: return self._patch_jadeite() + + def unpatch_game(self, game: Game): + pass diff --git a/vollerei/paths.py b/vollerei/paths.py index 18180a9..0ad8b23 100644 --- a/vollerei/paths.py +++ b/vollerei/paths.py @@ -1,21 +1,23 @@ from pathlib import Path +from os import PathLike from platformdirs import PlatformDirs base_paths = PlatformDirs("vollerei", "tretrauit", roaming=True) -tools_data_path: Path = None -tools_cache_path: Path = None -launcher_cache_path: Path = None -utils_cache_path: Path = None +cache_path = base_paths.site_cache_path +data_path = base_paths.site_data_path +tools_data_path = data_path.joinpath("tools") +tools_cache_path = cache_path.joinpath("tools") +launcher_cache_path = cache_path.joinpath("launcher") +utils_cache_path = cache_path.joinpath("utils") -def init_paths(): - global tools_data_path, tools_cache_path, launcher_cache_path, utils_cache_path - tools_data_path = base_paths.site_data_path.joinpath("tools") - tools_cache_path = base_paths.site_cache_path.joinpath("tools") - launcher_cache_path = base_paths.site_cache_path.joinpath("launcher") - utils_cache_path = base_paths.site_cache_path.joinpath("utils") - tools_data_path.mkdir(parents=True, exist_ok=True) - tools_cache_path.mkdir(parents=True, exist_ok=True) - launcher_cache_path.mkdir(parents=True, exist_ok=True) - utils_cache_path.mkdir(parents=True, exist_ok=True) +def change_base_path(path: PathLike): + path = Path(path) + global base_paths, tools_data_path, tools_cache_path, launcher_cache_path, utils_cache_path, cache_path, data_path + cache_path = path.joinpath("cache") + data_path = path.joinpath("data") + tools_data_path = data_path.joinpath("tools") + tools_cache_path = cache_path.joinpath("tools") + launcher_cache_path = cache_path.joinpath("launcher") + utils_cache_path = cache_path.joinpath("utils")