Repository navigation
fix: Linux 包带上各发行版的 Prisma 引擎,初始化失败时界面给出提示 (#86) - #93
Merged
Merged
Conversation
A failed database initialization was swallowed: the app kept running with every database feature broken and nothing telling the user why (#86). - initDatabase returns its outcome and runs once, and the renderer shows a persistent alert with the error through app:getDatabaseStatus. - Services that need the database don't start when it's unavailable. - runMigrations throws on the first failure instead of logging it and going on to apply later migrations on top of an incomplete schema. - Each migration runs in one transaction. Its statements could otherwise land on different pooled connections, whose stale schema cache made a RENAME after a DROP TABLE fail at random with "there is already another table", leaving the database half migrated: 19 of 640 replays failed before, 0 of 640 after. - The window opens after the migrations, so that no query sees them half done.
Linux packages only held the engine of the Ubuntu build machine, while Prisma picks one from the distro family and libssl of the user's machine. On Fedora, RHEL, openSUSE and any OpenSSL 1.1 distro it found none (#86). - Generate debian/rhel x OpenSSL 1.1/3.0 engines on x64 and both OpenSSL arm64 engines on arm64. binaryTargets comes from PRISMA_BINARY_TARGETS, set by scripts/prisma-cli.mjs, so a package never holds engines of the other arch. - verify:package requires each of them, and verify:package:distros checks in containers that Fedora, Rocky 8 and Ubuntu 20.04 load the engine meant for them. Both CI and the release workflow run it. - Leave the unused engine copies of the Prisma CLI out of the package. - Remove sharp, which segfaults in Electron on Fedora 44: its libvips bundles glib while Electron links the system's. Conversion only used it to read the page image, so it now reads the file. EXIF is no longer stripped from uploaded images as a side effect.
Contributor
Author
一、审查结论不通过。 去掉 sharp 后,用户上传图片里的 GPS 和设备信息会原样发给模型服务商,属于高级隐私问题,PR 描述里写明了风险也不能降级。Prisma 多引擎配置和迁移事务本身正确,未发现阻塞问题;但 #92 与本 PR 存在 git 报不全的语义冲突,后合入的一方必须处理。 二、审查明细
重点项核查结果(未发现缺陷)
未验证
附:跑过的测试及结果所有测试和复现都在
|
Removing sharp also removed the re-encoding it did on the way out: uploads reached the model provider byte for byte, with their GPS position and device details, and much larger (a 4000x3000 JPEG: 8.48 MB, was 3.29 MB). - ImageSplitter re-encodes uploads through @napi-rs/canvas at sharp's default quality, and fails rather than fall back to the original. The Exif orientation is applied to the pixels, so photos stay upright. - ModelService re-encodes any page file that may still hold metadata. Retrying a task reuses its page files, and those of older versions are plain copies. - Reject truncated images. Unlike sharp, the decoder draws what's there and leaves the rest blank, so a page would silently lose its text. - Pin @napi-rs/canvas to 1.0.11. Up to 1.0.3 it segfaults on damaged images, which would crash the app on each start, and 1.0.12 and 1.0.13 segfault in Electron as soon as they load. The load check now covers both. - Mount all of scripts/ in the distro containers: the load check requires fixtures/count-dark-pixels.cjs, which the PDF rendering check of #92 can share instead of its use of sharp.
A database left half migrated by an older version, or one that lost the record of a migration, fails on every start, while the alert only said to restart. initDatabase now also returns the database path when the file is what's failing, and the alert gives it with the steps to back it up and rebuild it. A missing engine keeps the old text, since a new database would fail as well.
…-engines Brings in #91 and #92, both of which still relied on sharp. - pdf-render-check.cjs and the PDF rendering test count pixels through count-dark-pixels.cjs and @napi-rs/canvas. - package-load-check.cjs: no checkSharp, and both checkPdfRendering and the Prisma engine it reports. - ModelService: no sharp, keeping providerSuffix from #91 and the re-encoding. - ProviderEndpoint.test: drop its mock of sharp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #86
改动
scripts/prisma-engines.mjs(列出各架构需要的引擎)和scripts/prisma-cli.mjs(按构建机的架构设置PRISMA_BINARY_TARGETS);schema.prisma改成binaryTargets = env("PRISMA_BINARY_TARGETS")。Linux x64 和 arm64 包会带上 debian、rhel 两类系统下 openssl-1.1.x 和 3.0.x 的引擎;npx 模式只生成本机用的引擎。verify-package-arch.mjs要求 Linux 包带齐全部目标引擎;新增verify:package:distros,用 Docker 在 Fedora 44、Rocky 8、Ubuntu 20.04 上加载包,并加进 ci.yml 和 release.yml。容器挂载整个scripts/目录。initDatabase返回{success, error, databasePath};新增app:getDatabaseStatusIPC 和常驻提示DatabaseStatusAlert(6 种语言);数据库不可用时不启动 worker。迁移失败时,界面显示可复制的数据库路径和 4 步「备份后重建」说明(移走文件而不是删除,可以撤回);Prisma 引擎缺失仍显示原来的提示。ImageReencoder,ImageSplitter改成用 canvas 解码后重新编码:JPEG 和 WebP 用质量 80(和 sharp 默认一致),PNG 无损。这样 EXIF、PNG 的 eXIf/tEXt 等元数据都会被清除,图片按 EXIF 方向转正。ModelService发送前会检查元数据标记,有就重新编码,覆盖升级前留下的旧任务重试。@napi-rs/canvas精确锁定在 1.0.11:0.1.88 解码损坏图片时会段错误,1.0.12 和 1.0.13 在 Electron 里一加载就崩。scripts/fixtures/count-dark-pixels.cjs),删掉了checkSharp。测试
npm run test:unit:1175 个用例全部通过;npm run test:renderer:308 个通过;typecheck、lint通过;verify:package(linux-x64)通过。需要注意
npx prisma generate会报缺环境变量,要改用npm run generate。未验证项
verify:package。