[ BUG ] --debug leaves an HTML dump in TMPDIR for remote documents
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc internal/core/usecase/localmd/localmd.go và internal/core/usecase/remotemd/remotemd.go, sau đó chạy bản tái hiện với TMPDIR từ issue. Theo dõi cách debug dump và việc dọn dẹp tệp tạm bị trì hoãn tương tác với nhau, đồng thời xác minh rằng remote --debug không còn để lại dump mồ côi mà vẫn duy trì khả năng kiểm tra đầu ra như dự định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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).
- Ngôn ngữ chính
- Go
- Star
- 525
- Fork
- 90
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ekalinin/github-markdown-toc.go
-
[Feature] Usage as a libraryĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
[BUG] TOC picks up YAMLĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
Tất cả issue của ekalinin/github-markdown-toc.go
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
open-telemetry/opentelemetry-go-compile-instrumentation#1417 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
agent-research-finding agent-research-recommend chore ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
jordansmall/spindrift#4068 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Type/Task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
OpenNSW/nsw-srilanka#537 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
security
Độ khó 2/5 1-2 ngày Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày