Add sfdupes info: show the database's details (closes #117) #123

Merged
clawbot merged 1 commits from issue-117-info into next 2026-10-16 22:41:17 +02:00
Collaborator

Implements #117.

sfdupes info prints the database's details on stdout, one per line as a name, a tab and the value: the path and where it came from, the sizes of the database file and of its -wal file when there is one, when the database file last changed, the schema version, and the record counts the issue lists. README "info mode" shows the layout.

It opens the database as report does, with the same first line on stderr and the same missing-database error, and shows [1/2] open and [2/2] count. The schema version and the counts are read in one read-only transaction, the counts by one query, so count has no total and its ETA is unknown.

What the diff does not show:

  • The -wal file is looked for beside the database's path with symlinks resolved, where SQLite keeps it; TestRunInfoDuringScan covers a symlinked database.
  • seedDatabase now closes test databases out of WAL mode, as scan does. Left in WAL mode, info's own read-only connection creates an empty -wal file and reports it.
  • openPhase and openingDatabase became constants because the linter asked for them once a third command used them, and newScanCommand exists because newRootCommand went over the linter's length limit. Neither changes behavior.

Judgement call: the lines are written after the count display has ended, so nothing is drawn while they are written, and they go straight to stdout rather than through the display's writer from #113.

Model: opus-5-5

Implements https://git.eeqj.de/sneak/sfdupes/issues/117. `sfdupes info` prints the database's details on stdout, one per line as a name, a tab and the value: the path and where it came from, the sizes of the database file and of its `-wal` file when there is one, when the database file last changed, the schema version, and the record counts the issue lists. README "`info` mode" shows the layout. It opens the database as `report` does, with the same first line on stderr and the same missing-database error, and shows `[1/2] open` and `[2/2] count`. The schema version and the counts are read in one read-only transaction, the counts by one query, so `count` has no total and its ETA is unknown. What the diff does not show: - The `-wal` file is looked for beside the database's path with symlinks resolved, where SQLite keeps it; `TestRunInfoDuringScan` covers a symlinked database. - `seedDatabase` now closes test databases out of WAL mode, as `scan` does. Left in WAL mode, `info`'s own read-only connection creates an empty `-wal` file and reports it. - `openPhase` and `openingDatabase` became constants because the linter asked for them once a third command used them, and `newScanCommand` exists because `newRootCommand` went over the linter's length limit. Neither changes behavior. Judgement call: the lines are written after the `count` display has ended, so nothing is drawn while they are written, and they go straight to stdout rather than through the display's writer from https://git.eeqj.de/sneak/sfdupes/issues/113. Model: opus-5-5
clawbot added the needs-review label 2026-10-16 22:02:11 +02:00
clawbot self-assigned this 2026-10-16 22:02:11 +02:00
Author
Collaborator

Review: changes needed.

  1. db.go lines 82, 134 and 265: the comments on errNoDatabase, reportParams and openReportDatabase still say they are for report and trees, but info now uses all three. A reader who follows runInfo into openReportDatabase, or who looks up the error info returns for a missing database, finds docs that leave info out. Acceptable: each of the three comments names info beside report and trees, as this change already does for run in main.go.

Model: opus-5-5

Review: changes needed. 1. `db.go` lines 82, 134 and 265: the comments on `errNoDatabase`, `reportParams` and `openReportDatabase` still say they are for `report` and `trees`, but `info` now uses all three. A reader who follows `runInfo` into `openReportDatabase`, or who looks up the error `info` returns for a missing database, finds docs that leave `info` out. Acceptable: each of the three comments names `info` beside `report` and `trees`, as this change already does for `run` in `main.go`. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-16 22:23:05 +02:00
clawbot added needs-review and removed needs-rework labels 2026-10-16 22:29:53 +02:00
clawbot added 1 commit 2026-10-16 22:29:53 +02:00
info prints the database's path and source, the sizes of the database
file and its -wal file, when the database file last changed, the schema
version and the record counts, one per line as a name, a tab and the
value. It opens the database as report does and shows an open and a
count phase on stderr. The schema version and the counts come from one
read-only transaction, the counts from one query.

seedDatabase now closes test databases out of WAL mode, as scan does;
otherwise info's own connection creates an empty -wal file. The open
phase's name and text became constants for the linter, and the scan
command moved to newScanCommand to keep newRootCommand short enough.

Judgement call: the lines are written after the last display ends, so they skip the display's stdout writer.

Model: opus-5-5
clawbot force-pushed issue-117-info from 0b0fb6bd27 to ded0ac11ae 2026-10-16 22:29:53 +02:00 Compare
Author
Collaborator

Rework for #123 (comment): the comments on errNoDatabase, reportParams and openReportDatabase in db.go now name info beside report and trees. Nothing else changed.

Model: opus-5-5

Rework for https://git.eeqj.de/sneak/sfdupes/pulls/123#issuecomment-145194: the comments on `errNoDatabase`, `reportParams` and `openReportDatabase` in `db.go` now name `info` beside `report` and `trees`. Nothing else changed. Model: opus-5-5
Author
Collaborator

Review passed: the finding from #123 (comment) is fixed and nothing else changed.

Model: opus-5-5

Review passed: the finding from https://git.eeqj.de/sneak/sfdupes/pulls/123#issuecomment-145194 is fixed and nothing else changed. Model: opus-5-5
clawbot merged commit e9e09effc6 into next 2026-10-16 22:41:17 +02:00
clawbot deleted branch issue-117-info 2026-10-16 22:41:17 +02:00
Sign in to join this conversation.