fix(runtime): 修复本地导入失效与默认版本无法切换 - #10
Merged
Merged
Conversation
本地导入时若目标版本号已存在(如已下载的 1.12.7),import 直接静默返回成功而不复制文件,导致托管目录始终只有一个运行时:前端"已导入"判断(按路径包含匹配)永远失败,用户也无法切换默认版本(因为只有一个可选项)。 - Changed: import 记录导入来源路径元数据(import_meta.json),list_installed 返回 imported_from - Changed: 版本号冲突时以来源目录名作后缀生成独立槽位(如 1.12.7-FrankenPHP),同一来源重复导入时复用槽位 - Changed: InstalledRuntime/RuntimeInfo/前端 RuntimeInfo 均透传 imported_from;isImported 改用来源路径精确匹配 - Changed: 来源路径 canonicalize 后剥离 \?\ 前缀,保证与检测路径可比 - Why: 用户本地有多个 FrankenPHP 时需能分别导入并随时切换默认版本
导入的运行时在列表中显示托管副本路径(AppData 下),与用户预期不符。 - Changed: 路径列对导入项显示原始来源路径,悬停提示托管副本路径;下载安装项不变 - Why: 用户导入本地二进制后期望看到自己的原始路径,托管副本属于实现细节
导入本地 FrankenPHP 不再复制到 runtimes/ 目录,保留用户原始位置。 - Changed: import 移除 std::fs::copy/set_executable,仅写 import_meta.json - Changed: ImportResult.path 直接返回来源路径;list_installed 中导入项的 path 字段即 imported_from - Changed: find_import_slot 改为优先复用同源裸版本号槽位(已写入元数据),否则生成带来源目录名后缀 - Changed: read_import_meta 校验来源文件是否仍存在,丢失时自动清理元数据 - Changed: write_import_meta 自建中间目录,便于独立调用 - Changed: 单元测试改用 portable-foo/portable-bar 目录名匹配新断言 下载安装行为不变:二进制落到 data_dir/runtimes/<version>/frankenphp.exe。
lopinx
force-pushed
the
fix/lopinx/runtime-import-switch
branch
from
August 22, 2026 14:11
030ab87 to
bfcc2be
Compare
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.
问题
import直接静默返回成功而不复制文件,托管目录始终只有一个运行时,无其他版本可切换。isImported用路径包含匹配(托管目录路径不可能包含检测到的原始路径),判断永远失败。修复
import记录导入来源路径元数据(import_meta.json),list_installed返回imported_from1.12.7-FrankenPHP),同一来源重复导入时复用槽位InstalledRuntime/RuntimeInfo/ 前端RuntimeInfo均透传imported_from;isImported改用来源路径精确匹配canonicalize后剥离\\?\前缀,保证与检测路径可比较验证
cargo test -p runphp-core --lib runtime:5 passedcargo build --workspace:通过npx vue-tsc --noEmit:通过