fix: read WebUI versions from the served asset directory (#10156)

This commit is contained in:
Wei Chengqian
2026-09-21 16:27:08 +08:00
committed by GitHub
parent 3ada8aa0ae
commit 95e98b8aed
3 changed files with 27 additions and 11 deletions
+7 -1
View File
@@ -100,7 +100,12 @@ def create_dashboard_asgi_app(
app.state.jwt_secret = jwt_secret
app.state.dashboard_static_folder = static_folder
log_broker = getattr(core_lifecycle, "log_broker", None) or LogBroker()
stats = StatService(db, core_lifecycle, core_lifecycle.astrbot_config)
stats = StatService(
db,
core_lifecycle,
core_lifecycle.astrbot_config,
dashboard_static_folder=static_folder,
)
app.state.services = SimpleNamespace(
config_profiles=ConfigProfileService(core_lifecycle, db, runtime=stats.runtime),
config_display=ConfigDisplayService(core_lifecycle),
@@ -141,6 +146,7 @@ def create_dashboard_asgi_app(
pip_install_func=call_pip_install,
demo_mode=DEMO_MODE,
clear_site_data_headers=CLEAR_SITE_DATA_HEADERS,
dashboard_static_folder=static_folder,
),
)
+15 -9
View File
@@ -58,10 +58,13 @@ class StatService:
db_helper: BaseDatabase,
core_lifecycle: AstrBotCoreLifecycle,
config: AstrBotConfig,
*,
dashboard_static_folder: str | None = None,
) -> None:
self.db_helper = db_helper
self.core_lifecycle = core_lifecycle
self.config = config
self.dashboard_static_folder = dashboard_static_folder
self.storage_cleaner = StorageCleaner(config)
# Probe sandbox startup once; restart AstrBot to refresh this snapshot.
@@ -153,7 +156,9 @@ class StatService:
if is_desktop_session_auth_enabled():
return {
"version": VERSION,
"dashboard_version": await get_dashboard_version(),
"dashboard_version": await get_dashboard_version(
self.dashboard_static_folder
),
"change_pwd_hint": False,
"md5_pwd_hint": False,
"password_upgrade_required": False,
@@ -171,7 +176,9 @@ class StatService:
md5_pwd_hint = is_md5_dashboard_password(password)
return {
"version": VERSION,
"dashboard_version": await get_dashboard_version(),
"dashboard_version": await get_dashboard_version(
self.dashboard_static_folder
),
"change_pwd_hint": await self.is_default_cred(),
"md5_pwd_hint": md5_pwd_hint,
"password_upgrade_required": not storage_upgraded,
@@ -186,7 +193,7 @@ class StatService:
Args:
dashboard_static_folder: Static WebUI dist directory currently served by
the dashboard, when available.
the dashboard. Defaults to the directory configured on the service.
Returns:
Public WebUI and AstrBot version information.
@@ -219,12 +226,11 @@ class StatService:
dashboard_version = None
try:
if dashboard_static_folder:
dashboard_version = await get_dashboard_version(
Path(dashboard_static_folder)
)
if dashboard_version is None:
dashboard_version = await get_dashboard_version()
dashboard_version = await get_dashboard_version(
dashboard_static_folder
if dashboard_static_folder is not None
else self.dashboard_static_folder
)
except Exception as exc:
logger.warning("Failed to read public WebUI version: %s", exc)
+5 -1
View File
@@ -50,6 +50,7 @@ class UpdateService:
pip_install_func: Callable[..., Awaitable[Any]],
demo_mode: bool,
clear_site_data_headers: dict,
dashboard_static_folder: str | None = None,
) -> None:
self._updater = astrbot_updater
self.core_lifecycle = core_lifecycle
@@ -57,6 +58,7 @@ class UpdateService:
self.pip_install = pip_install_func
self.demo_mode = demo_mode
self.clear_site_data_headers = clear_site_data_headers
self.dashboard_static_folder = dashboard_static_folder
self.update_progress: dict[str, dict] = {}
self._update_tasks: dict[str, asyncio.Task] = {}
@@ -73,7 +75,9 @@ class UpdateService:
async def check_update(self, update_type: str | None) -> UpdateServiceResult:
try:
dashboard_version = await self.get_dashboard_version()
dashboard_version = await self.get_dashboard_version(
self.dashboard_static_folder
)
if update_type == "dashboard":
return UpdateServiceResult(
data={