From 2846e3edd1bea4534a836849ee4b20a580a92d30 Mon Sep 17 00:00:00 2001 From: SashegDev Date: Thu, 30 Jul 2026 11:29:45 +0000 Subject: [PATCH] feat: auto-detect new ZIP archives in builds/ + fix exe download path --- server/main.py | 24 +++++++++++++++++++++--- todo.txt | 9 +++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 todo.txt diff --git a/server/main.py b/server/main.py index 118bf1a..79c3370 100644 --- a/server/main.py +++ b/server/main.py @@ -227,6 +227,24 @@ async def lifespan(app: FastAPI): asyncio.create_task(periodic_sync()) + # Background task: auto-detect new ZIP archives in builds/ and register them + async def watch_new_zips(): + watch_interval = int(os.environ.get("ZIP_WATCH_INTERVAL", "15")) + while True: + await asyncio.sleep(watch_interval) + try: + before = set(f.name for f in VERSIONS_DIR.iterdir()) if VERSIONS_DIR.exists() else set() + extract_new_format_versions() + after = set(f.name for f in VERSIONS_DIR.iterdir()) if VERSIONS_DIR.exists() else set() + new_versions = after - before + if new_versions: + logger.info(f"New launcher versions detected: {', '.join(sorted(new_versions))}") + generate_launcher_builds_meta() + except Exception as e: + logger.warning(f"ZIP watch error: {e}") + + asyncio.create_task(watch_new_zips()) + yield # Cleanup proxy client @@ -1567,12 +1585,12 @@ async def get_launcher_version(): "updated_at": datetime.utcnow().isoformat() } - jar_path = BUILDS_DIR / "ZernMCLauncher.jar" + jar_path = BUILDS_DIR / "zernmclauncher.jar" if jar_path.exists(): response["download_jar"] = "/launcher/download/jar" response["jar_size"] = jar_path.stat().st_size - exe_path = BUILDS_DIR / "ZernMCLauncher.exe" + exe_path = BUILDS_DIR / "zernmc.exe" if exe_path.exists(): response["download_exe"] = "/launcher/download/exe" response["exe_size"] = exe_path.stat().st_size @@ -1611,7 +1629,7 @@ async def download_launcher_jar(request: Request = None): @app.get("/launcher/download/exe") async def download_launcher_exe(request: Request = None): """Download launcher EXE file (Windows)""" - file_path = BUILDS_DIR / "ZernMCLauncher.exe" + file_path = BUILDS_DIR / "zernmc.exe" if not file_path.exists(): raise HTTPException(404, "EXE file not found") diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..df27646 --- /dev/null +++ b/todo.txt @@ -0,0 +1,9 @@ +TODO / ideas backlog +==================== + +Java Agent + IPC (low priority, overkill now) +- Заменить прямой ProcessBuilder.start() на прокси-класс (-javaagent или -cp прокси) +- Прокси класс: подключается к localhost RPC, ждёт "launch", потом reflection вызывает реальный main +- Даёт: двустороннюю связь лаунчер-игра, контроль жизненного цикла, crash-репорты из процесса игры, + передачу настроек/токенов на лету, патчинг классов через Instrumentation API +- Для ZernMC сейчас оверхед — но запомнить на будущее