Skip to content

fix(fs): stop truncating names with spaces in companion ls/find output - #75

Merged
qiffang merged 1 commit into
mainfrom
fix/fs-ls-find-filename-spaces
Oct 7, 2026
Merged

qiffang merged 1 commit into
mainfrom
fix/fs-ls-find-filename-spaces

Conversation

@mornyx

@mornyx mornyx commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #73

Problem

ti fs list-files and ti fs find-files returned alpha for a file named alpha beta.txt (reproduced across three directories; ti fs grep-file-content shares 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:

  • parseDrive9LS split drive9 fs ls -l lines with strings.Fields and kept fields[2], but the companion prints kind<TAB>size<TAB>name through a space-padding tabwriter — the name is the final column and may contain spaces, so it was cut at the first space.
  • parseDrive9Paths kept fields[0] of each line, but drive9 fs find prints the whole path per line (and fs grep prints path<TAB>score), so paths containing spaces were truncated at the first space.

Change

  • parseDrive9LS now 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.
  • parseDrive9Paths treats 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

  • TestParseDrive9LSPreservesNamesWithSpaces
  • TestParseDrive9LSSkipsMalformedLines
  • TestParseDrive9PathsPreservesSpaces (find paths, :-prefixed paths, grep path<TAB>score, limit)

Full go test ./... passes.

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
@ti-chi-bot ti-chi-bot Bot added the size/M label Oct 6, 2026

@qiffang qiffang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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。

@qiffang
qiffang merged commit efd7efa into main Oct 7, 2026
2 checks passed
@mornyx
mornyx deleted the fix/fs-ls-find-filename-spaces branch October 7, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] fs list-files and find-files truncate names that contain spaces

2 participants