Repository navigation
fix(fs): stop truncating names with spaces in companion ls/find output - #75
Merged
Merged
Conversation
parseDrive9LS split `drive9 fs ls -l` lines with strings.Fields and kept only fields[2], cutting the final name column at its first space; the companion prints "kind<TAB>size<TAB>name" through a space-padding tabwriter, so only the kind and size tokens are fixed. parseDrive9Paths kept fields[0] of each line, truncating `fs find` paths (and `fs grep` paths) at the first space even though the whole line is the path except for grep's TAB-separated score. Parse the two fixed ls tokens and cut paths only at tabs so names and paths keep their spaces. Fixes #73
qiffang
approved these changes
Oct 6, 2026
qiffang
left a comment
Collaborator
There was a problem hiding this comment.
Review round 1 — exact HEAD 204a3261be8c120d2209d6cb48b42d9b28646b95. Verdict: APPROVED.
本轮修复与真实 companion 输出合同一致,未发现 blocker:
drive9 fs ls -l的 producer 使用tabwriter输出kind<TAB>size<TAB>name;实际展开后只有 kind/size 是固定 token,name 是最终列。新 parser 只解析前两个 token、保留 name 中的内部及连续空格,并对缺 name/非法 size 的行 fail-closed 跳过,不再伪造 size=0 entry。drive9 fs find每行输出完整 path;fs grep仅在 score 存在时输出path<TAB>score。parseDrive9Paths只在 TAB 处截断,因而保留 path 内部空格;既有:remote-prefix、basename 和 limit 语义保持。- 我用 Drive9 producer 的相同
text/tabwriter配置复现了实际 ls 排版,结果与新 fixture 一致。将生产 parser 临时恢复到 base 旧实现后,3 个新增回归(ls 空格、malformed 行、find/grep 空格)均确定性失败,证明测试对原 bug 敏感。
验证:目标测试 -count=20、go vet ./internal/fs、全仓 build、diff check 均通过;exact HEAD 为 MERGEABLE,GitHub test 与 CLA checks 均 SUCCESS。无遗留 blocker。
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 #73
Problem
ti fs list-filesandti fs find-filesreturnedalphafor a file namedalpha beta.txt(reproduced across three directories;ti fs grep-file-contentshares the path parser and is equally affected). The service data is intact — the HTTP API returns the full name — this is purely companion-output parsing:parseDrive9LSsplitdrive9 fs ls -llines withstrings.Fieldsand keptfields[2], but the companion printskind<TAB>size<TAB>namethrough a space-padding tabwriter — the name is the final column and may contain spaces, so it was cut at the first space.parseDrive9Pathskeptfields[0]of each line, butdrive9 fs findprints the whole path per line (andfs grepprintspath<TAB>score), so paths containing spaces were truncated at the first space.Change
parseDrive9LSnow parses the two fixed tokens (kind, size) and keeps the remainder verbatim as the name; internal (including multiple consecutive) spaces survive. Malformed lines (non-numeric size, missing name) are skipped instead of yielding size-0 entries.parseDrive9Pathstreats each line as a path and cuts only at a TAB (grep's score separator), preserving spaces in paths; the:prefix strip is unchanged.Known limitation: a filename that starts with spaces still loses them in
ls -l, because the tabwriter's column padding is indistinguishable from them in the text format.Test
TestParseDrive9LSPreservesNamesWithSpacesTestParseDrive9LSSkipsMalformedLinesTestParseDrive9PathsPreservesSpaces(find paths,:-prefixed paths, greppath<TAB>score, limit)Full
go test ./...passes.