Compare commits

...

3 Commits

Author SHA1 Message Date
2144b1e0eb 补充解压 Typst 构建产物需要的依赖
All checks were successful
continuous-integration/drone/push Build is passing
2026-04-28 00:39:37 +08:00
7d0d53bead 修复并调整构建产物的生命周期
All checks were successful
continuous-integration/drone/push Build is passing
2026-04-28 00:35:03 +08:00
4bfcc9b41c Merge pull request '修复偶发的数据库连接失效问题' (#72) from fix/database-lock into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #72
2026-04-28 00:12:44 +08:00
3 changed files with 23 additions and 7 deletions

View File

@ -5,6 +5,8 @@ ENV VIRTUAL_ENV=/app/.venv \
PLAYWRIGHT_BROWSERS_PATH=/usr/lib/pw-browsers
# 安装所有都需要的底层依赖
#
# xz-utils: 解压需要它
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libfontconfig1 libgl1 libegl1 libglvnd0 mesa-vulkan-drivers at-spi2-common fontconfig \
@ -16,6 +18,7 @@ RUN apt-get update && \
libatk-bridge2.0-0t64 libatspi2.0-0t64 libxcomposite1 libxdamage1 libxfixes3 \
libxkbcommon0 libasound2t64 libnss3 fonts-noto-cjk fonts-noto-cjk-extra \
fonts-noto-color-emoji \
xz-utils \
&& rm -rf /var/lib/apt/lists/*

View File

@ -50,7 +50,14 @@ class ArtifactDepends:
tasks = set()
for f in self.callbacks:
tasks.add(f(downloaded))
return await asyncio.gather(*tasks, return_exceptions=True)
result = await asyncio.gather(*tasks, return_exceptions=True)
for r in result:
if isinstance(r, BaseException):
logger.warning("完成了二进制文件的下载,但是有未捕捉的错误")
logger.exception(r)
return result
class Config(BaseModel):
@ -73,12 +80,7 @@ async def _():
async def _task(artifact: ArtifactDepends):
async with semaphore:
downloaded = await ensure_artifact(artifact)
result = await artifact._finished(downloaded)
for r in result:
if isinstance(r, BaseException):
logger.warning("完成了二进制文件的下载,但是有未捕捉的错误")
logger.exception(r)
await ensure_artifact(artifact)
tasks: set[asyncio.Task] = set()
for a in artifact_list:
@ -116,9 +118,16 @@ async def download_artifact(artifact: ArtifactDepends):
f"下载到的二进制的 sha256 与需求不同 TARGET={artifact.target} REQUESTED={artifact.sha256} ACTUAL={m.hexdigest()}"
)
await artifact._finished(True)
async def ensure_artifact(artifact: ArtifactDepends) -> bool:
"""
确保所需的二进制存在。返回是否下载了这个二进制文件。
"""
if not artifact.is_corresponding_platform():
logger.debug(f"所需求的平台不是当前平台,跳过二进制下载 artifact={artifact}")
return False
if not artifact.target.exists():
@ -136,6 +145,7 @@ async def ensure_artifact(artifact: ArtifactDepends) -> bool:
artifact.target.unlink()
await download_artifact(artifact)
return True
await artifact._finished(False)
return False

View File

@ -41,6 +41,7 @@ bin_path: Path | None = None
@arti_typst_linux.on_finished
async def _(downloaded: bool):
logger.debug("安装好了 Linux 版本的 Typst")
global bin_path
tar_path = arti_typst_linux.target
@ -71,6 +72,7 @@ async def _(downloaded: bool):
@arti_typst_windows.on_finished
async def _(downloaded: bool):
logger.debug("安装好了 Windows 版本的 Typst")
global bin_path
zip_path = arti_typst_windows.target
bin_path = BINARY_PATH / "typst.exe"
@ -160,6 +162,7 @@ async def _(
# 对于本地机器,一般不会在应用启动时自动下载,这里再保证存在
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