An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Cache OCR runtime archives in the repository
Daniel830a7af8a9c9
diff --git a/.gitignore b/.gitignoreindex 2a1c553531..7e83ae6873 100644--- a/.gitignore+++ b/.gitignore@@ -51,5 +51,6 @@ muslbin/# Workflows**/__pycache__# OCR 模型和运行时由固定版本、校验摘要的发布准备脚本生成+/.cache/ocr//app/stage/ocr/models//app/stage/ocr/runtime/diff --git a/docs/RELEASE-VERIFICATION.zh-CN.md b/docs/RELEASE-VERIFICATION.zh-CN.mdindex 9b7fed30e6..e227426b41 100644--- a/docs/RELEASE-VERIFICATION.zh-CN.md+++ b/docs/RELEASE-VERIFICATION.zh-CN.md@@ -106,6 +106,7 @@ WSL 同步安排在环境检查和签名证书检查之前。如果 SSH 需要### 3. 准备构建环境- 准备 Go、Node、pnpm、Windows 双架构编译器、gomobile、Android SDK/NDK、DevEco Studio 和 7-Zip;Appx 还需 `electron-windows-store`+- OCR 运行库归档缓存位于项目的 `.cache/ocr/`;手动下载时保留原文件名,不解压,脚本校验摘要后复用- 停止正在运行的前端开发构建- 插好 YubiKey,签名时按系统提示输入 PIN- 确认 Android、鸿蒙签名配置可用diff --git a/scripts/prepare-ocr.py b/scripts/prepare-ocr.pyindex 5e718f7111..cda30ad091 100644--- a/scripts/prepare-ocr.py+++ b/scripts/prepare-ocr.py@@ -22,6 +22,7 @@ import zipfileROOT = Path(__file__).resolve().parents[1]MANIFEST = json.loads(Path(__file__).with_name("ocr-assets.json").read_text(encoding="utf-8"))STAGE = ROOT / "app/stage/ocr"+CACHE = ROOT / ".cache/ocr"RUNTIME_STAMP = "onnxruntime-files.json"@@ -338,7 +339,7 @@ def prepare_runtime(target, build_worker, prerequisites=None):if runtime_is_verified(entry, directory):print(f"Reusing verified OCR runtime: {target}")else:- cache = Path(tempfile.gettempdir()) / "siyuan-ocr-assets" / entry["url"].rsplit("/", 1)[1]+ cache = CACHE / entry["url"].rsplit("/", 1)[1]download(entry, cache)record_runtime(entry, directory, extract_runtime(entry, cache, directory))# 本地依赖每次重新准备,复用归档产物不跳过 CRT 校验或工作进程构建。diff --git a/scripts/test_prepare_ocr.py b/scripts/test_prepare_ocr.pyindex fbe7d0f4a1..c2b8e5893a 100644--- a/scripts/test_prepare_ocr.py+++ b/scripts/test_prepare_ocr.py@@ -255,7 +255,7 @@ class ResourceTests(unittest.TestCase):def extract(self, archive, target, library):entry = self.entry(archive)entry["library"] = library- with patch.object(prepare, "STAGE", self.root / "stage"), patch.object(prepare, "MANIFEST", {"runtime": {target: entry}}), patch.object(prepare.tempfile, "gettempdir", return_value=str(self.root / "cache")):+ with patch.object(prepare, "STAGE", self.root / "stage"), patch.object(prepare, "MANIFEST", {"runtime": {target: entry}}), patch.object(prepare, "CACHE", self.root / "cache"):prepare.prepare_runtime(target, False)def runtime_archive(self):@@ -272,10 +272,10 @@ class ResourceTests(unittest.TestCase):entry = {**self.entry(archive), "library": "libonnxruntime.so"}with patch.object(prepare, "STAGE", self.root / "stage"), \patch.object(prepare, "MANIFEST", {"runtime": {"linux-amd64": entry}}), \- patch.object(prepare.tempfile, "gettempdir", return_value=str(self.root / "cache")):+ patch.object(prepare, "CACHE", self.root / "cache"):prepare.prepare_runtime("linux-amd64", False)archive.unlink()- (self.root / "cache/siyuan-ocr-assets/runtime.tgz").unlink()+ (self.root / "cache/runtime.tgz").unlink()with patch.object(prepare, "download") as download:prepare.prepare_runtime("linux-amd64", False)download.assert_not_called()@@ -323,7 +323,7 @@ class ResourceTests(unittest.TestCase):entry = {**self.entry(archive), "library": "libonnxruntime.so"}with patch.object(prepare, "STAGE", self.root / "stage"), \patch.object(prepare, "MANIFEST", {"runtime": {"linux-amd64": entry}}), \- patch.object(prepare.tempfile, "gettempdir", return_value=str(self.root / "cache")):+ patch.object(prepare, "CACHE", self.root / "cache"):prepare.prepare_runtime("linux-amd64", False)library = self.root / "stage/runtime/linux-amd64/libonnxruntime.so"library.write_bytes(b"damaged")@@ -339,7 +339,7 @@ class ResourceTests(unittest.TestCase):with patch.dict(os.environ, {"SIYUAN_OCR_VC_REDIST_DIR": str(source)}), \patch.object(prepare, "STAGE", self.root / "stage"), \patch.object(prepare, "MANIFEST", {"runtime": {"windows-amd64": entry}}), \- patch.object(prepare.tempfile, "gettempdir", return_value=str(self.root / "cache")):+ patch.object(prepare, "CACHE", self.root / "cache"):prepare.prepare_runtime("windows-amd64", False)dependency = self.root / "stage/runtime/windows-amd64/msvcp140.dll"dependency.unlink()@@ -353,7 +353,7 @@ class ResourceTests(unittest.TestCase):entry = {**self.entry(archive), "library": "libonnxruntime.so"}with patch.object(prepare, "STAGE", self.root / "stage"), \patch.object(prepare, "MANIFEST", {"runtime": {"linux-amd64": entry}}), \- patch.object(prepare.tempfile, "gettempdir", return_value=str(self.root / "cache")):+ patch.object(prepare, "CACHE", self.root / "cache"):prepare.prepare_runtime("linux-amd64", False)with patch.object(prepare, "download") as download, patch.object(prepare.subprocess, "run") as build:prepare.prepare_runtime("linux-amd64", True, {"CC": "gcc"})