Name the database each command uses on stderr (closes #111)
check / check (push) Canceled after 0s
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:
@@ -91,13 +91,22 @@ var errSchemaVersion = errors.New("unsupported database schema version")
|
||||
var errScanRunning = errors.New("another scan is running")
|
||||
|
||||
// databasePath resolves the database location: SFDUPES_DATABASE when
|
||||
// set and non-empty, the compiled-in default otherwise.
|
||||
func databasePath() string {
|
||||
// set and non-empty, the compiled-in default otherwise. It returns the
|
||||
// path made absolute against the working directory, and where the path
|
||||
// came from, "default" or "from SFDUPES_DATABASE", for the line each
|
||||
// subcommand prints first on stderr.
|
||||
func databasePath() (string, string, error) {
|
||||
path, source := defaultDatabasePath, "default"
|
||||
if p := os.Getenv(databaseEnv); p != "" {
|
||||
return p
|
||||
path, source = p, "from "+databaseEnv
|
||||
}
|
||||
|
||||
return defaultDatabasePath
|
||||
abs, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("resolve database path %s: %w", path, err)
|
||||
}
|
||||
|
||||
return abs, source, nil
|
||||
}
|
||||
|
||||
// scanParams are the connection parameters for scan: read-write, with
|
||||
|
||||
Reference in New Issue
Block a user