check / check (push) Canceled after 0s
The walk neither enters nor records an --exclude path or anything below it, and prints "scan: skipped PATH (--exclude)" for each one it reaches. The flag repeats. Each value is resolved to its real path, as an operand is. The records below an excluded path are kept, as for a default exclude. An --exclude path that does not exist, or an operand at or below one, is a fatal error before the scan starts. Model: opus-5-5
39 lines
927 B
Go
39 lines
927 B
Go
package sfdupes
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
// runDwim implements the dwim subcommand: it runs what "sfdupes scan
|
|
// root" runs with no flags, then what "sfdupes trees" runs, and ends
|
|
// with a line on stderr saying how to print the report again. The dwim
|
|
// command passes "/" as root. It catches SIGINT and SIGTERM as scan
|
|
// does, but only during the scan. An error from the scan, an interrupt
|
|
// included, ends it before the report. During the report, a signal
|
|
// ends it at once, as it ends trees.
|
|
func runDwim(ctx context.Context, root string, stdout io.Writer) error {
|
|
scanCtx, stop := interruptContext(ctx)
|
|
err := runScan(scanCtx, []string{root}, runtime.NumCPU(), false, false,
|
|
nil)
|
|
|
|
stop()
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = runTrees(ctx, stdout)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintln(os.Stderr,
|
|
`dwim: run "sfdupes trees" to print this report again`)
|
|
|
|
return nil
|
|
}
|