From 42d8d19cc432d18244aaab82b3d6106bae832e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Thu, 7 May 2026 02:29:33 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20live-=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=B2?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=82=D1=87=20=D1=83=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D1=89=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/patch_update_center.py | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/patch_update_center.py b/scripts/patch_update_center.py index 0f4525e..72d99e1 100644 --- a/scripts/patch_update_center.py +++ b/scripts/patch_update_center.py @@ -9,9 +9,7 @@ if not app_path.exists(): script_dir = Path(__file__).resolve().parent -# New installs run this patch from install_web_panel.sh. Keep feature patches here too -# so a fresh install gets disk images, conversion progress, VM architecture selector, -# ARM64 emulation XML path, orphan disk replacement, dashboard update notifications and update center. +# New installs run this patch from install_web_panel.sh. Keep feature patches here too. for optional_patch in ('patch_disk_images.py', 'patch_disk_convert_progress.py', 'patch_vm_architecture.py', 'patch_arm64_emulation_xml.py', 'patch_vm_disk_replace.py', 'patch_update_badge.py'): patch_path = script_dir / optional_patch if patch_path.exists(): @@ -64,6 +62,19 @@ def update_page(request: Request): return templates.TemplateResponse("update.html", {"request": request, "app_name": APP_NAME, "user": AUTH_USER, "info": info, "error": error}) +@app.get("/update/status") +def update_status(request: Request): + auth_redirect = require_auth(request) + if auth_redirect: + return JSONResponse({"ok": False, "error": "auth required"}, status_code=401) + return JSONResponse({ + "ok": True, + "state": update_core.state(), + "log_tail": update_core.update_log_tail(260), + "checked_at": utc_now(), + }) + + @app.post("/update/check") def update_check(request: Request): auth_redirect = require_auth(request) @@ -95,7 +106,28 @@ if '@app.get("/update"' not in text: text = text.replace(marker, routes + marker, 1) changed.append('update routes added') else: - changed.append('update routes already present') + if '@app.get("/update/status"' not in text: + marker = '\n\n@app.post("/update/check")' + if marker not in text: + raise SystemExit('update/check route marker not found') + status_route = r''' + +@app.get("/update/status") +def update_status(request: Request): + auth_redirect = require_auth(request) + if auth_redirect: + return JSONResponse({"ok": False, "error": "auth required"}, status_code=401) + return JSONResponse({ + "ok": True, + "state": update_core.state(), + "log_tail": update_core.update_log_tail(260), + "checked_at": utc_now(), + }) +''' + text = text.replace(marker, status_route + marker, 1) + changed.append('update status route added') + else: + changed.append('update status route already present') app_path.write_text(text) print('update center patch applied:')