Peach: Local-first video metadata scraper and media manager.
fix(desktop): 构建与验收使用公开发行资源
longmeidao66e9ca066792
diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 53d57eff3..1152e2fb5 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -512,7 +512,7 @@ A 盘垃圾隔离使用短名称 `peach-purge-<32 位 UUID>.peach-quarantine`,- macOS Ledger 同步在共享根判为 `offline` 时先经 NetFS 挂载 `peach-sync` 再重判,挂载失败才保留离线结果,不弹阻塞认证框。- 浏览历史增量采集使用 SQLite backup API 与 `browserexport`,也接受 Google Takeout ZIP;原始 URL 与标题只留本机私有目录,聚合候选不写 ledger。- 首次设置的可选历史引导转到 `/taste?onboarding=1`,用现有读取与导入入口;指南链接按 [Google 导出说明](https://support.google.com/accounts/answer/3024190?hl=zh-Hans) 与 [browserexport](https://github.com/purarue/browserexport) 核验(2026-09-06)。-- 实体事实包默认保存在私有数据根:`scripts/seed_pack.py export` 只读账本生成 `state/seed/entities.json`,不随仓库或发行包分发(ADR-0111)。已有私有包由扫描结算后的种子后继导入,幂等键绑定内容摘要。v2 结构校验复用已固定的 Pydantic,SQLite 历史表记录版本、修订与累计精确撤销,防止旧包回放;别名保留源 confidence,用户资料由归属保护。种子不含图片;包中缺席不视为错误撤销。分发边界、复核与纠错见 ADR-0073、ADR-0075、[ADR-0106](adr/0106-seed-correction-history-and-explicit-withdrawals.md)。+- 实体事实包默认保存在私有数据根:`scripts/seed_pack.py export` 只读账本生成 `state/seed/entities.json`,不随仓库或发行包分发(ADR-0111)。Windows 构建与制品验收均拒绝发行资源中的 `seed` 目录。已有私有包由扫描结算后的种子后继导入,幂等键绑定内容摘要。v2 结构校验复用已固定的 Pydantic,SQLite 历史表记录版本、修订与累计精确撤销,防止旧包回放;别名保留源 confidence,用户资料由归属保护。种子不含图片;包中缺席不视为错误撤销。分发边界、复核与纠错见 ADR-0073、ADR-0075、[ADR-0106](adr/0106-seed-correction-history-and-explicit-withdrawals.md)。- 数据管理首屏直接复用实际 `cleanupfieldset` 正文和操作条,只有计数等待取数;资源同步与重复文件网盘操作根据 `/api/sources` 已配置来源显示,离线来源保留入口。资源同步的检查与执行覆盖已配置的 local、115、PikPak,一次检查同时报失效记录、空文件夹与孤儿缓存;按目录清理也支持本地磁盘。## 必须复用的成熟实现diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1index b0187c036..b7cb04ef1 100644--- a/scripts/build_windows.ps1+++ b/scripts/build_windows.ps1@@ -35,8 +35,9 @@ if (-not (Test-Path -LiteralPath (Join-Path $ProjectRoot 'resources\peach.ico')throw 'Brand assets are missing. Run scripts/generate_brand_assets.py first.'}-& $Python -X utf8 (Join-Path $PSScriptRoot 'seed_pack.py') validate --pack (Join-Path $ProjectRoot 'resources\seed\entities.json')-if ($LASTEXITCODE -ne 0) { throw 'The bundled entity seed did not pass validation.' }+if (Test-Path -LiteralPath (Join-Path $ProjectRoot 'resources\seed')) {+ throw 'Private entity exports must stay outside the application resources directory.'+}# Frontend bundles ship inside `--add-data web;web` and the runtime has no Node, so they# must be rebuilt here: web/dist is committed to Git, but packaging reads the working tree,diff --git a/scripts/smoke_desktop.py b/scripts/smoke_desktop.pyindex 227f952a2..f47d91ba7 100644--- a/scripts/smoke_desktop.py+++ b/scripts/smoke_desktop.py@@ -53,6 +53,11 @@ def assert_av1_decoder(ffmpeg: Path, root: Path) -> None:assert image.is_file() and image.stat().st_size > 0, 'AV1 抽帧未取得'+def assert_public_resources(application: Path) -> None:+ """发行资源不包含本机实体导出。"""+ assert not (application / "_internal/resources/seed").exists(), "发行包包含私有实体导出"++def assert_bundled_media_tools(application: Path) -> None:"""在没有系统媒体工具的机器上验证随包转码、探测和抽帧。"""tools = application / "tools" / "ffmpeg"@@ -71,9 +76,7 @@ def assert_bundled_media_tools(application: Path) -> None:assert path.resolve().is_relative_to(untrunc_root.resolve()), namewith path.open("rb") as stream:assert hashlib.file_digest(stream, "sha256").hexdigest() == expected, name- # resources 是冻结资源的一部分,首次扫描可读到随版本附带的种子。- seed = json.loads((application / "_internal/resources/seed/entities.json").read_text(encoding="utf-8"))- assert seed["version"] and seed["entities"], "随包种子缺失"+ assert_public_resources(application)ffmpeg, ffprobe = tools / "bin/ffmpeg.exe", tools / "bin/ffprobe.exe"with tempfile.TemporaryDirectory(prefix="peach-media-smoke-") as directory:root = Path(directory).resolve()@@ -447,7 +450,7 @@ def main() -> int:assert (data / "config.previous.toml").is_file()assert (data / "state" / "configuration-reload.request").is_file()print(json.dumps({"ok": True, "version": health.get("version"),- "checks": ["oobe", "migrations", "lan-bind", "mdns", "password-login", "unauthenticated-api", "pages", "island", "items", "clouddrive-configuration", "cloudflared-sidecar", "bundled-media-tools", "seed-pack"]}))+ "checks": ["oobe", "migrations", "lan-bind", "mdns", "password-login", "unauthenticated-api", "pages", "island", "items", "clouddrive-configuration", "cloudflared-sidecar", "bundled-media-tools", "public-resources"]}))finally:process.terminate()process.wait(timeout=15)diff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex ff757f0df..7298f2764 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -226,6 +226,21 @@ class DesktopSmokeTests(unittest.TestCase):def setUpClass(cls):cls.script = load_script("smoke_desktop")+ def test_distribution_resources_accept_an_application_without_private_exports(self):+ with tempfile.TemporaryDirectory() as directory:+ application = Path(directory).resolve()+ (application / '_internal/resources').mkdir(parents=True)+ self.script.assert_public_resources(application)++ def test_distribution_resources_reject_private_entity_exports(self):+ with tempfile.TemporaryDirectory() as directory:+ application = Path(directory).resolve()+ seed = application / '_internal/resources/seed'+ seed.mkdir(parents=True)+ (seed / 'entities.json').write_text('{}', encoding='utf-8')+ with self.assertRaisesRegex(AssertionError, '私有实体导出'):+ self.script.assert_public_resources(application)+def test_cleanup_waits_for_a_released_windows_directory(self):error = PermissionError('目录仍被占用')error.winerror = 32