Reject scan --workers below 1 as a usage error (closes #10)
check / check (push) Failing after 1s

A --workers value of 0 or less used to be quietly raised to 1, so a
typo ran the whole scan on one worker with nothing on stderr to say
why. scan now refuses it before anything is scanned: one line on
stderr and exit 2, like the other usage errors. The clamp in runScan
is gone, and README states the rule and the default.

Model: opus-5-5
This commit is contained in:
2026-10-04 11:41:38 +00:00
parent 8032ea682b
commit e932aaef0d
5 changed files with 69 additions and 10 deletions
+6 -3
View File
@@ -566,7 +566,9 @@ Rules for the walk:
Concurrency: the walk phase (which also stats files), the hash phase,
and the content phase each use a worker pool of `--workers` workers
(default `runtime.NumCPU()`); the walk parallelizes across
directories, hashing across files. All three phases are seek-bound on
directories, hashing across files. `--workers` must be at least 1: a
smaller value is a usage error, reported in one line on stderr with
exit 2 before anything is scanned. All three phases are seek-bound on
spinning disks, so raising `--workers` well past the core count can
help on pools with many spindles. The main goroutine owns
partitioning, database writes, and progress rendering; progress
@@ -761,8 +763,9 @@ Additional requirements:
cannot be created/opened/read/written, a missing database for
`report`/`trees`, stdout write failure), or a `scan` stopped by
`SIGINT` or `SIGTERM` (see below).
- `2`: usage error (including `scan` with no `PATH` operand and
`report`/`trees` with any positional argument).
- `2`: usage error (including `scan` with no `PATH` operand, `scan`
with `--workers` below 1, and `report`/`trees` with any positional
argument).
A stdout write failure, such as a full disk, is reported in one line on
stderr and exits 1. Two cases never reach sfdupes as a failed write: