Repository navigation
fix: 子文件夹多级路径被静默截断为最后一级 - #18
Merged
freestylefly merged 1 commit intoSep 30, 2026
Merged
Conversation
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 #16
动机
设置 → 沉淀到 Obsidian 的「子文件夹」填多级路径(如
参考/微信流)时,KnowledgeDelivery.deliver把整个值交给DisplayName.sanitize,而sanitize的第一步取lastPathComponent——路径被静默截断为最后一级(微信流),前面的层级被丢弃且无任何提示,归档落在非预期位置。改动
DisplayName新增subfolderPath(_:):按/拆段 → 每段独立过sanitize→ 过滤空段 → 重新以/连接;无可用段时返回空串。sanitize本体不动——它的语义是单个文件名的消毒(清洗归档名等多处依赖其lastPathComponent行为),多级路径需要的是路径级处理,两者不该互相迁就。KnowledgeDelivery改用subfolderPath,空结果回退默认「微信流」(与原行为一致);下游createDirectory(withIntermediateDirectories: true)天然支持多级创建,无需其他改动。DisplayNameTests新增 7 条断言:多级保留 / 空段过滤(a//b、/a/b/)/ 段内非法字符清洗(a:b/c→a-b/c)/ 空串与 nil / 单级不回归。安全性说明(预答)
..段会被sanitize的 fallback 前缀中和(实测"a/../b"→"a/共享文件../b"),无法逃出知识库文件夹。createDirectory处干净失败(ENAMETOOLONG),无残留目录。验证
swift test:151 tests, 0 failures(基线 150 + 新增 1;变异检查确认——若实现退回sanitize,7 条断言中至少 3 条必红)参考/微信流后转发聊天记录,笔记与附件确认落盘在<知识库>/参考/微信流/check-localizations在当前main基线上即 exit=1(65 条存量失败,与技能包相关),与本改动无关——已用 stash 基线对照逐字节确认界面变化
无(纯逻辑修复)。