Repository navigation
fix(binding): resolve mirrors through junctions and symlinks (#173) - #177
Merged
Merged
Conversation
`resolveMirror` compared the session cwd with the mirror root as raw strings. `path.resolve` is purely lexical, so a cwd in the REAL spelling never matched a registry root spelled through `%USERPROFILE%\.dsh` (NTFS Junction) — the session was reported as LOCAL and every rw_* tool refused it, even though the mirror and its meta were right there. Scan both the literal and the real-path spelling of the registry root, compare case-insensitively on Windows (drive-letter case is not stable), and re-spell the reported mirrorDir the way the cwd spells it so downstream path mapping compares like with like. Non-mirror directories still never bind. The three new cases create a real junction (Windows) / directory symlink (POSIX) and SKIP when the OS refuses; two of them fail on the old code.
`spellLike` rebuilt the path from split segments, which dropped the leading `/` on POSIX (`/tmp/x` came back as `tmp/x`) — Windows passed only because the drive segment (`C:`) carried the root. Step up with `path.dirname` instead, so `/`, `C:\` and UNC roots all survive.
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 #173.
问题
resolveMirror()把会话 cwd 与镜像根当纯字符串比前缀。path.resolve是词法的,不解析 Junction/symlink:%USERPROFILE%\.dsh是指向真实目录的 NTFS Junction 时,镜像根按 Junction 形式拼写,而会话 cwd 常以真实路径形式到达;rw_*全部拒绝,只有rw_connect/rw_pick_workspace可用。改动
mirrorDir会按 cwd 的拼写重新表达(spellLike),使下游路径映射两侧可比;与
lib/workspace-cleanup.js里既有的realpathSync做法保持一致。测试
新增 3 条用例,真实创建 junction(Windows)/ 目录符号链接(POSIX),OS 拒绝时 skip 而非静默通过:
mirrorDir用 cwd 拼写;mirrorDir用链接拼写;machine === null。负对照:还原实现后,用例 1、2 失败(
machine为 null),修复后全绿——证明它们不是永远绿。