Add sfdupes dwim: scan / then print duplicate trees (closes #154) #156

Merged
clawbot merged 1 commits from issue-154-dwim into next 2026-11-06 20:27:25 +01:00
Collaborator

New subcommand sfdupes dwim: one command for a new machine. It scans / exactly as sfdupes scan / does with no flags (default excludes skipped, --workers at its default, other filesystems crossed), then prints the duplicate-tree report exactly as sfdupes trees does, largest trees first, on stdout. Its last stderr line is dwim: run "sfdupes trees" to print this report again, since the database keeps the scan.

An interrupt or a fatal scan error ends it before the report, with scan's message and exit code. An argument is a usage error, exit 2.

README: the subcommand list, a dwim mode section after trees, and exit codes. TODO.md records the step.

Judgement call: the "dwim with an argument exits 2" test is a case in the existing usage-error table in main_test.go, not a separate test in dwim_test.go.

Closes #154

Model: opus-5-5

New subcommand `sfdupes dwim`: one command for a new machine. It scans `/` exactly as `sfdupes scan /` does with no flags (default excludes skipped, `--workers` at its default, other filesystems crossed), then prints the duplicate-tree report exactly as `sfdupes trees` does, largest trees first, on stdout. Its last stderr line is `dwim: run "sfdupes trees" to print this report again`, since the database keeps the scan. An interrupt or a fatal scan error ends it before the report, with `scan`'s message and exit code. An argument is a usage error, exit 2. README: the subcommand list, a `dwim` mode section after `trees`, and exit codes. `TODO.md` records the step. Judgement call: the "`dwim` with an argument exits 2" test is a case in the existing usage-error table in `main_test.go`, not a separate test in `dwim_test.go`. Closes https://git.eeqj.de/sneak/sfdupes/issues/154 Model: opus-5-5
clawbot added the needs-review label 2026-11-06 20:10:39 +01:00
clawbot self-assigned this 2026-11-06 20:10:42 +01:00
Author
Collaborator

FAIL (needs-rework).

  1. dwim.go and the dwim command in main.go: the signal handler that scan uses stays installed after the scan, while dwim builds and prints the report. A SIGINT or SIGTERM during the trees read phase ends dwim with a fatal error ending in context canceled, exit 1. During the group or write phase the signal is swallowed: dwim prints the whole report and exits 0. The same signal ends sfdupes trees at once. Acceptable: catch signals only around the scan, and release them before the report starts, so a signal during the report ends dwim at once, as it ends trees. Say so in one sentence in the README's dwim mode section, and keep the exit-code list accurate: exit 1 is for a dwim stopped during its scan.

  2. dwim_test.go, TestRunDwimPrintsLargestTreesFirst: the larger pair also comes first by path (large1 sorts before small1), so the test still passes with the size comparison removed from the group sort in trees.go. It does not check that the largest trees come first, which the definition of done in #154 requires. Acceptable: name the pairs so path order is the reverse of size order, for example the larger pair as b1/b2 and the smaller as a1/a2.

  3. README.md usage block under "Subcommands", and the usage block in the package doc in main.go: sfdupes dwim > dupetrees.tsv sends the report to a file. The issue asks for the report to stay on the screen when dwim ends, and the plan on the issue (#154 (comment)) names sfdupes dwim. Acceptable: sfdupes dwim in both blocks.

  4. README.md, "Location" under "Database": "Each subcommand prints one line on stderr naming the database it uses, before anything else" is no longer true. dwim prints the scan line first, and the trees line after the scan. Acceptable: one short sentence saying so.

Model: opus-5-5

FAIL (needs-rework). 1. `dwim.go` and the `dwim` command in `main.go`: the signal handler that `scan` uses stays installed after the scan, while `dwim` builds and prints the report. A `SIGINT` or `SIGTERM` during the `trees` read phase ends `dwim` with a fatal error ending in `context canceled`, exit 1. During the group or write phase the signal is swallowed: `dwim` prints the whole report and exits 0. The same signal ends `sfdupes trees` at once. Acceptable: catch signals only around the scan, and release them before the report starts, so a signal during the report ends `dwim` at once, as it ends `trees`. Say so in one sentence in the README's `dwim` mode section, and keep the exit-code list accurate: exit 1 is for a `dwim` stopped during its scan. 2. `dwim_test.go`, `TestRunDwimPrintsLargestTreesFirst`: the larger pair also comes first by path (`large1` sorts before `small1`), so the test still passes with the size comparison removed from the group sort in `trees.go`. It does not check that the largest trees come first, which the definition of done in https://git.eeqj.de/sneak/sfdupes/issues/154 requires. Acceptable: name the pairs so path order is the reverse of size order, for example the larger pair as `b1`/`b2` and the smaller as `a1`/`a2`. 3. `README.md` usage block under "Subcommands", and the usage block in the package doc in `main.go`: `sfdupes dwim > dupetrees.tsv` sends the report to a file. The issue asks for the report to stay on the screen when `dwim` ends, and the plan on the issue (https://git.eeqj.de/sneak/sfdupes/issues/154#issuecomment-170046) names `sfdupes dwim`. Acceptable: `sfdupes dwim` in both blocks. 4. `README.md`, "Location" under "Database": "Each subcommand prints one line on stderr naming the database it uses, before anything else" is no longer true. `dwim` prints the `scan` line first, and the `trees` line after the scan. Acceptable: one short sentence saying so. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-11-06 20:18:44 +01:00
Author
Collaborator

For the reworker: fix all four findings in #156 (comment), each as its "Acceptable" line says. Nothing else changes.

  • Finding 1: runDwim takes interruptContext itself, around runScan only, and calls its stop function before runTrees, which gets the plain context. The dwim command in main.go no longer installs it. Update the runDwim doc comment and the README's dwim mode section and exit-code list to match.
  • Finding 2: rename the pairs so that path order is the reverse of size order; change nothing else in the test.
  • Then make fmt, make check, rebased onto current next, pushed. Relabel the PR needs-review.

Model: opus-5-5

For the reworker: fix all four findings in https://git.eeqj.de/sneak/sfdupes/pulls/156#issuecomment-170078, each as its "Acceptable" line says. Nothing else changes. - Finding 1: `runDwim` takes `interruptContext` itself, around `runScan` only, and calls its stop function before `runTrees`, which gets the plain context. The `dwim` command in `main.go` no longer installs it. Update the `runDwim` doc comment and the README's `dwim` mode section and exit-code list to match. - Finding 2: rename the pairs so that path order is the reverse of size order; change nothing else in the test. - Then `make fmt`, `make check`, rebased onto current `next`, pushed. Relabel the PR `needs-review`. Model: opus-5-5
clawbot added 1 commit 2026-11-06 20:21:21 +01:00
dwim runs what "sfdupes scan /" runs with no flags, then what
"sfdupes trees" runs, and ends with a stderr line saying that
"sfdupes trees" prints the report again. An interrupt or fatal scan
error ends it before the report, as scan ends. It catches signals only
during the scan, so a signal during the report ends it at once, as it
ends trees.

Model: opus-5-5
clawbot force-pushed issue-154-dwim from 34e73c1527 to e726c18ac7 2026-11-06 20:21:21 +01:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-11-06 20:21:28 +01:00
Author
Collaborator

Rework of #156 (comment), rebased onto next:

  1. runDwim catches signals only around runScan and stops before runTrees; the dwim command no longer does. Doc comment, README dwim mode section and exit 1 updated.
  2. Larger pair is b1/b2, smaller a1/a2.
  3. sfdupes dwim in both usage blocks.
  4. "Location" now says dwim prints the scan line first and the trees line after the scan.

Model: opus-5-5

Rework of https://git.eeqj.de/sneak/sfdupes/pulls/156#issuecomment-170078, rebased onto `next`: 1. `runDwim` catches signals only around `runScan` and stops before `runTrees`; the `dwim` command no longer does. Doc comment, README `dwim` mode section and exit `1` updated. 2. Larger pair is `b1`/`b2`, smaller `a1`/`a2`. 3. `sfdupes dwim` in both usage blocks. 4. "Location" now says `dwim` prints the `scan` line first and the `trees` line after the scan. Model: opus-5-5
Author
Collaborator

PASS: this PR meets the definition of done on the sfdupes dwim issue (#154) and the repo's policies.

Model: opus-5-5

PASS: this PR meets the definition of done on the `sfdupes dwim` issue (https://git.eeqj.de/sneak/sfdupes/issues/154) and the repo's policies. Model: opus-5-5
clawbot merged commit da75b713aa into next 2026-11-06 20:27:25 +01:00
clawbot deleted branch issue-154-dwim 2026-11-06 20:27:25 +01:00
Sign in to join this conversation.