Compare commits
2 Commits
6a2fe11753
...
8725f28caf
| Author | SHA1 | Date | |
|---|---|---|---|
|
8725f28caf
|
|||
|
fef9041a97
|
@ -15,7 +15,7 @@ from nonebot.adapters.onebot.v11.event import MessageEvent as OB11MessageEvent
|
||||
from nonebot.adapters.onebot.v11.bot import Bot as OB11Bot
|
||||
from nonebot.adapters.onebot.v11.message import Message as OB11Message
|
||||
|
||||
from konabot.common.artifact import ArtifactDepends, register_artifacts
|
||||
from konabot.common.artifact import ArtifactDepends, ensure_artifact, register_artifacts
|
||||
from konabot.common.longtask import DepLongTaskTarget
|
||||
from konabot.common.path import BINARY_PATH, TMP_PATH
|
||||
|
||||
@ -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,7 +155,13 @@ async def _(
|
||||
msg: UniMsg,
|
||||
target: DepLongTaskTarget,
|
||||
):
|
||||
if bin_path is None:
|
||||
global bin_path
|
||||
|
||||
# 对于本地机器,一般不会在应用启动时自动下载,这里再保证存在
|
||||
await ensure_artifact(arti_typst_linux)
|
||||
await ensure_artifact(arti_typst_windows)
|
||||
if bin_path is None or not bin_path.exists():
|
||||
logger.warning("当前环境不存在 Typst,但仍然调用了")
|
||||
return
|
||||
|
||||
typst_code = ""
|
||||
|
||||
Reference in New Issue
Block a user