Name the database each command uses on stderr (closes #111)
check / check (push) Canceled after 0s

scan, report and trees now print one line on stderr before anything
else, naming the database as an absolute path and saying whether the
path is the default or comes from SFDUPES_DATABASE; scan also says when
no database file exists yet. report and trees print it before opening
the database, so a missing-database error follows it. databasePath in
db.go now returns the absolute path and its source, and every command
uses that absolute path throughout, so errors and the lock file name it
too. README "Database" lists when scan writes each file, from the lock
file to the -wal and -shm files going away.

Unverified: the line on a terminal has no test of its own; it is
printed before any progress display, the same way in both cases.

Model: opus-5-5
This commit is contained in:
2026-10-16 12:02:46 +00:00
parent 198cefa152
commit ff14c28ee7
9 changed files with 226 additions and 35 deletions
+9 -3
View File
@@ -29,10 +29,16 @@ type treeNode struct {
// the record paths, computes a Merkle-style digest per directory, and
// prints maximal duplicate-tree groups as TSV on stdout. It never
// touches the scanned filesystem; its only I/O is the database, stdout,
// and stderr. Any database problem, including a missing database, is
// fatal.
// and stderr. It names the database on stderr before it opens it. Any
// database problem, including a missing database, is fatal.
func runTrees(ctx context.Context, stdout io.Writer) error {
dbPath := databasePath()
dbPath, source, err := databasePath()
if err != nil {
return err
}
fmt.Fprintf(os.Stderr, "trees: database %s (%s)\n",
escapePath(dbPath), source)
db, err := openReportDatabase(ctx, dbPath)
if err != nil {