[ BUG ] --debug leaves an HTML dump in TMPDIR for remote documents
还没有人认领这个 Issue。
评估
调研方向
先阅读 internal/core/usecase/localmd/localmd.go 和 internal/core/usecase/remotemd/remotemd.go,然后运行 issue 中使用 TMPDIR 的复现步骤。跟踪调试转储与延迟的临时文件清理如何交互,并验证 remote --debug 不再留下孤立的转储,同时保留按预期检查输出的能力。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
With --debug, a run against a remote URL leaves an orphaned ghtoc-remote-txt-*.debug.html file in the temporary directory. Nothing ever removes it, so the files accumulate.
RemoteMd downloads the document into a temporary file and delegates to LocalMd. In debug mode LocalMd writes its HTML dump next to the file it was handed, producing <temp>.debug.html. RemoteMd's deferred cleanup removes only the downloaded copy, not the dump.
The dump is also useless where it lands: it is named after a random temporary file, so there is no obvious way to connect it back to the URL that produced it.
To Reproduce
export TMPDIR=/tmp/ghtoc-dbg && mkdir -p "$TMPDIR"
gh-md-toc --debug https://raw.githubusercontent.com/ekalinin/github-markdown-toc.go/master/README.md > /dev/null
ls -1 "$TMPDIR"
Actual:
ghtoc-remote-txt-482196719.debug.html
Expected: nothing left in TMPDIR, or a dump the user can actually find.
Expected behavior
Two reasonable options, and the choice affects whether --debug stays useful for remote input:
- Remove it.
RemoteMddeletes<temp>.debug.htmlalongside the temporary Markdown. Smallest change, but--debugthen produces nothing inspectable for a remote document, which defeats the flag for that input type. - Relocate it. Write the dump into the working directory under a name derived from the URL, for example
README.md.debug.html. Keeps the flag useful and matches what already happens for local files, where the dump lands next to the document and is covered by the*.debug.htmlrule in.gitignore.
Environment (please complete the following information):
- OS: macOS (darwin/arm64), reproduces on any platform
- Version: reproduced at 2.0.1 and on current
master
Additional context
Pre-existing, not introduced by any open pull request.
The same class of bug affected --skip-header, where the dump was named after an internal trimmed copy and stranded in TMPDIR the same way. That one is fixed in #79 by naming the dump after the document the user passed rather than after the internal temporary file. RemoteMd was deliberately left out of that change: its display path is a URL, not a filesystem path, so the same fix does not apply directly and the destination is a real decision rather than a mechanical one.
See internal/core/usecase/localmd/localmd.go (debug dump) and internal/core/usecase/remotemd/remotemd.go (temporary file cleanup).
- 主要语言
- Go
- 星标
- 525
- 派生
- 90
- 平均合并
- 2 天 1 小时
- 30 天内合并 PR
- 1
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ekalinin/github-markdown-toc.go 的其他 Issue
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
-
bug
难度 2/5 1-3 小时 新手友好度 45/100
查看 ekalinin/github-markdown-toc.go 的全部 Issue
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 92/100
open-telemetry/opentelemetry-go-compile-instrumentation#1417 ·
维护者通常 2 天内回复
-
agent-research-finding agent-research-recommend chore ready-for-agent
难度 2/5 1-3 小时 新手友好度 85/100
jordansmall/spindrift#4068 · 1 条评论 ·
维护者通常 1 天内回复
-
Type/Task
难度 2/5 1-3 小时 新手友好度 74/100
OpenNSW/nsw-srilanka#537 ·
维护者通常 1 天内回复
-
security
难度 2/5 1-2 天 新手友好度 62/100
-
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复