Repository navigation
fix(transfer): resolve deepest existing ancestor in pathsOverlap - #263
Merged
Merged
Conversation
Signed-off-by: chialecode <315431287+chialecode@users.noreply.github.com>
Owner
Author
|
Agent:独立审查结论(head 已审查范围
阻塞问题无(P0 / P1 / P2 均为 0)。 非阻塞建议无。 未覆盖部分(
|
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.
Closes #261
做了什么
修复 Windows Runner 上
Release Build Check在internal/transfer触发的TestExportRejectsLibraryOverlapAndFiltersMissingFiles失败(Export accepted subdirectory of CacheDir as destination):internal/transfer/export.go中的pathsOverlap(a, b)仅对输入路径本身调用filepath.EvalSymlinks。当b(lib.CacheDir())已存在而a(filepath.Join(lib.CacheDir(), "nested"))尚未创建时,EvalSymlinks(cb)成功并将 Windows 8.3 短路径(如RUNNER~1)或符号链接前缀展开,而EvalSymlinks(ca)返回os.ErrNotExist保留未展开前缀,导致filepath.Rel(cb, ca)判定为跨目录树并误返false。internal/transfer/export.go):canonicalizePathForOverlap(p string) string:先做filepath.Abs+filepath.Clean,再向上逐级查找最深已存在祖先目录并通过filepath.EvalSymlinks规范化(同时展开符号链接与 Windows 8.3 短路径),最后按序拼回尚未创建的后缀路径段。pathsOverlap(a, b)先处理空路径,再对双方调用canonicalizePathForOverlap,在 Windows 下统一小写后再经filepath.Rel双向校验包含关系。internal/transfer/export.go、scan.go、apply.go中其余路径包含与校验逻辑(均依托library.RejectDirectoryLinks、library.EnsureWithinRoot、library.ResolveItemPath或同一WalkDir根前缀),无同类缺陷。internal/transfer/transfer_test.go、internal/transfer/transfer_windows_test.go):CacheDir下尚未创建的多层嵌套子目录(a/b/c)、CacheDir父目录、同前缀兄弟目录(不误判)、空路径,以及指向CacheDir的符号链接祖先目录。windows.GetShortPathName复现 CI 根因,含shortCache+ 未创建shortNested调用Export)及目录联接祖先目录。验证
go test -v -count=1 ./internal/transfer/...:全部通过(含TestExportRejectsLibraryOverlapAndFiltersMissingFiles、TestPathsOverlapNonExistentSubdirsAndSymlinkAncestor(含symlink_ancestor)、TestPathsOverlapWindowsCaseShortPathAndJunction(含case_variation、short_path、junction_ancestor,零跳过))。GOOS=linux GOARCH=amd64 go vet ./internal/transfer/...:通过。go run ./tools/check:ALL CHECKS PASSED in 10m39.628s(gofmt、go vet、go test ./...、依赖方向、trace-serverLinux 构建、tools/checkdocs、git diff --check HEAD全部通过;在git worktree中先跑完门禁再按LESSONS.md使用git push --no-verify推送,避免pre-push钩子继承GIT_DIR污染工作树引用)。repository-qualityCI 通过。风险
internal/transfer导出目录重叠检查及其单元测试,不涉及接口变更、数据格式、凭证、打包发布、桌面壳或真实站点请求,未触及高风险清单(docs/dev-rules/workflow.md#high-risk)。风险等级:低风险
每个提交都带
Signed-off-by(git commit -s)。