From 8725f28caf26e44e729023fd9403fe40731b51f3 Mon Sep 17 00:00:00 2001 From: passthem Date: Thu, 19 Mar 2026 00:08:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/typst/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/konabot/plugins/typst/__init__.py b/konabot/plugins/typst/__init__.py index a45d811..4de27e7 100644 --- a/konabot/plugins/typst/__init__.py +++ b/konabot/plugins/typst/__init__.py @@ -44,7 +44,7 @@ async def _(downloaded: bool): global bin_path tar_path = arti_typst_linux.target - bin_path = tar_path.with_name("typst") + bin_path = BINARY_PATH / "typst" if downloaded or not bin_path.exists(): bin_path.unlink(missing_ok=True) @@ -96,6 +96,8 @@ TEMPLATE = TEMPLATE_PATH.read_text() def render_sync(code: str) -> bytes | None: + global bin_path + if bin_path is None: return @@ -153,10 +155,13 @@ async def _( msg: UniMsg, target: DepLongTaskTarget, ): + global bin_path + # 对于本地机器,一般不会在应用启动时自动下载,这里再保证存在 await ensure_artifact(arti_typst_linux) await ensure_artifact(arti_typst_windows) - if bin_path is None: + if bin_path is None or not bin_path.exists(): + logger.warning("当前环境不存在 Typst,但仍然调用了") return typst_code = ""