Add sfdupes info: show the database's details #117

Open
opened 2026-10-16 14:02:50 +02:00 by clawbot · 0 comments
Collaborator

sneak, on #56 (comment):

> 2. make sfdupes info show the database information: size, rows, etc.
>
> > root@las1stor1:~# SFDUPES_DATABASE="/srv/tmp/sfdupes/db.db" ./go/bin/sfdupes report > first dupe size > report: 0 records read, 0 duplicate groups, 0 dupe files, 0 B reclaimable >

Today the only way to look into the database is to run report and read its summary line.

Definition of done

  • A new subcommand sfdupes info, with no arguments (any argument is a usage error, exit 2, like report). It reads the database the way report does: read-only, without the scan lock, so it works during a running scan and as a user with only read access.
  • It prints, one item per line on stdout:
    • the database path, absolute, and where it came from (SFDUPES_DATABASE or the default), as #111 words it;
    • the size of the database file, and of its -wal file when one exists, in bytes and in human units;
    • the time the database file was last changed;
    • the schema version;
    • the number of records, how many have head and tail hashes, how many have a content hash, and the total size of the recorded files.
  • The exact layout is the implementer's, documented in README (a new "info mode" section, plus the usage lines in main.go's package doc and the README synopsis). Keep it plain and stable enough to read by eye and by grep, for example records 12345678.
  • A missing database is the same error as for report, exit 1.
  • While its counts run (seconds on a large database), it shows progress on stderr like the other commands: phase, elapsed time, and ETA where a total is known (#112, which lands first).
  • Tests: the output for an empty database and a small filled one, an argument given, a missing database. Keep each test well under a second (#109).
  • TODO.md Completed Steps entry in the same commit; script/cibuild green on a fresh clone.

Notes for the implementer

  • Package main (the repo's only package). The command goes in a new file info.go, beside report.go and trees.go; its queries go in db.go; the subcommand is wired up in main.go.
  • One query for the counts (a single pass over the table), not one per number.
  • Small and plain; no flags on the new subcommand, no new dependencies.

Model: opus-5-5

sneak, on https://git.eeqj.de/sneak/sfdupes/issues/56#issuecomment-145021: > 2. make `sfdupes info` show the database information: size, rows, etc. > > ``` > root@las1stor1:~# SFDUPES_DATABASE="/srv/tmp/sfdupes/db.db" ./go/bin/sfdupes report > first dupe size > report: 0 records read, 0 duplicate groups, 0 dupe files, 0 B reclaimable > ``` Today the only way to look into the database is to run `report` and read its summary line. ## Definition of done - A new subcommand `sfdupes info`, with no arguments (any argument is a usage error, exit 2, like `report`). It reads the database the way `report` does: read-only, without the scan lock, so it works during a running scan and as a user with only read access. - It prints, one item per line on stdout: - the database path, absolute, and where it came from (`SFDUPES_DATABASE` or the default), as https://git.eeqj.de/sneak/sfdupes/issues/111 words it; - the size of the database file, and of its `-wal` file when one exists, in bytes and in human units; - the time the database file was last changed; - the schema version; - the number of records, how many have head and tail hashes, how many have a content hash, and the total size of the recorded files. - The exact layout is the implementer's, documented in README (a new "`info` mode" section, plus the usage lines in `main.go`'s package doc and the README synopsis). Keep it plain and stable enough to read by eye and by `grep`, for example `records 12345678`. - A missing database is the same error as for `report`, exit 1. - While its counts run (seconds on a large database), it shows progress on stderr like the other commands: phase, elapsed time, and ETA where a total is known (https://git.eeqj.de/sneak/sfdupes/issues/112, which lands first). - Tests: the output for an empty database and a small filled one, an argument given, a missing database. Keep each test well under a second (https://git.eeqj.de/sneak/sfdupes/issues/109). - `TODO.md` Completed Steps entry in the same commit; `script/cibuild` green on a fresh clone. ## Notes for the implementer - Package `main` (the repo's only package). The command goes in a new file `info.go`, beside `report.go` and `trees.go`; its queries go in `db.go`; the subcommand is wired up in `main.go`. - One query for the counts (a single pass over the table), not one per number. - Small and plain; no flags on the new subcommand, no new dependencies. Model: opus-5-5
clawbot added this to the 1.0.0 milestone 2026-10-16 14:02:50 +02:00
Sign in to join this conversation.