Compare commits
1
Commits
next
..
34e73c1527
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34e73c1527 |
@@ -256,7 +256,7 @@ sfdupes scan [--workers N] [-x] [--no-default-excludes] PATH...
|
|||||||
sfdupes report > dupes.tsv
|
sfdupes report > dupes.tsv
|
||||||
sfdupes trees > dupetrees.tsv
|
sfdupes trees > dupetrees.tsv
|
||||||
sfdupes info
|
sfdupes info
|
||||||
sfdupes dwim
|
sfdupes dwim > dupetrees.tsv
|
||||||
sfdupes --version
|
sfdupes --version
|
||||||
sfdupes [command] --help
|
sfdupes [command] --help
|
||||||
```
|
```
|
||||||
@@ -828,8 +828,7 @@ even after the terminal is gone.
|
|||||||
`SIGINT` or `SIGTERM` stops the scan as it stops `scan` (see "Stopping a scan").
|
`SIGINT` or `SIGTERM` stops the scan as it stops `scan` (see "Stopping a scan").
|
||||||
`dwim` then prints no report and exits 1. A fatal scan error also ends it before
|
`dwim` then prints no report and exits 1. A fatal scan error also ends it before
|
||||||
the report, with the same message and exit code as `scan`. Warnings for skipped
|
the report, with the same message and exit code as `scan`. Warnings for skipped
|
||||||
files do not stop it. `dwim` stops catching signals when the scan ends, so a
|
files do not stop it.
|
||||||
signal during the report ends it at once, as it ends `trees`.
|
|
||||||
|
|
||||||
### `info` mode
|
### `info` mode
|
||||||
|
|
||||||
@@ -887,8 +886,6 @@ scan: new database /var/lib/sfdupes/db.sqlite (default)
|
|||||||
trees: database /srv/tmp/sfdupes/db.db (from SFDUPES_DATABASE)
|
trees: database /srv/tmp/sfdupes/db.db (from SFDUPES_DATABASE)
|
||||||
```
|
```
|
||||||
|
|
||||||
`dwim` prints the `scan` line first, and the `trees` line after the scan.
|
|
||||||
|
|
||||||
A relative path is printed with the working directory in front of it. The
|
A relative path is printed with the working directory in front of it. The
|
||||||
working directory is printed as `pwd -P` prints it, with its symlinks resolved.
|
working directory is printed as `pwd -P` prints it, with its symlinks resolved.
|
||||||
The rest of the path is printed as set, so a `..` in it stays. The line names
|
The rest of the path is printed as set, so a `..` in it stays. The line names
|
||||||
@@ -1172,8 +1169,8 @@ showing the count it stopped at.
|
|||||||
### Error handling and exit codes
|
### Error handling and exit codes
|
||||||
|
|
||||||
- `0`: success, even when files were skipped with warnings.
|
- `0`: success, even when files were skipped with warnings.
|
||||||
- `1`: a fatal error, a `scan` stopped by `SIGINT` or `SIGTERM`, or a `dwim`
|
- `1`: a fatal error, or a `scan` or `dwim` stopped by `SIGINT` or `SIGTERM`. A
|
||||||
stopped by either during its scan. A fatal error is one of these:
|
fatal error is one of these:
|
||||||
- an operand that does not exist, or whose real path `scan` cannot find;
|
- an operand that does not exist, or whose real path `scan` cannot find;
|
||||||
- a list of mounted filesystems that `scan` cannot read;
|
- a list of mounted filesystems that `scan` cannot read;
|
||||||
- another `scan` holding the lock (see "The scan lock");
|
- another `scan` holding the lock (see "The scan lock");
|
||||||
|
|||||||
@@ -11,16 +11,10 @@ import (
|
|||||||
// runDwim implements the dwim subcommand: it runs what "sfdupes scan
|
// runDwim implements the dwim subcommand: it runs what "sfdupes scan
|
||||||
// root" runs with no flags, then what "sfdupes trees" runs, and ends
|
// 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
|
// 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
|
// command passes "/" as root. An error from the scan, an interrupt
|
||||||
// does, but only during the scan. An error from the scan, an interrupt
|
// included, ends it before the report.
|
||||||
// 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 {
|
func runDwim(ctx context.Context, root string, stdout io.Writer) error {
|
||||||
scanCtx, stop := interruptContext(ctx)
|
err := runScan(ctx, []string{root}, runtime.NumCPU(), false, false)
|
||||||
err := runScan(scanCtx, []string{root}, runtime.NumCPU(), false, false)
|
|
||||||
|
|
||||||
stop()
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -16,12 +16,12 @@ func TestRunDwimPrintsLargestTreesFirst(t *testing.T) {
|
|||||||
root := realTempDir(t)
|
root := realTempDir(t)
|
||||||
|
|
||||||
small := []string{
|
small := []string{
|
||||||
filepath.Dir(writeFile(t, root, "a1/f.bin", pattern(1, 300))),
|
filepath.Dir(writeFile(t, root, "small1/f.bin", pattern(1, 300))),
|
||||||
filepath.Dir(writeFile(t, root, "a2/f.bin", pattern(1, 300))),
|
filepath.Dir(writeFile(t, root, "small2/f.bin", pattern(1, 300))),
|
||||||
}
|
}
|
||||||
large := []string{
|
large := []string{
|
||||||
filepath.Dir(writeFile(t, root, "b1/f.bin", pattern(2, 5000))),
|
filepath.Dir(writeFile(t, root, "large1/f.bin", pattern(2, 5000))),
|
||||||
filepath.Dir(writeFile(t, root, "b2/f.bin", pattern(2, 5000))),
|
filepath.Dir(writeFile(t, root, "large2/f.bin", pattern(2, 5000))),
|
||||||
}
|
}
|
||||||
|
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
// sfdupes report > dupes.tsv
|
// sfdupes report > dupes.tsv
|
||||||
// sfdupes trees > dupetrees.tsv
|
// sfdupes trees > dupetrees.tsv
|
||||||
// sfdupes info
|
// sfdupes info
|
||||||
// sfdupes dwim
|
// sfdupes dwim > dupetrees.tsv
|
||||||
// sfdupes --version
|
// sfdupes --version
|
||||||
//
|
//
|
||||||
// See README.md for the complete specification.
|
// See README.md for the complete specification.
|
||||||
@@ -208,6 +208,9 @@ func newRootCommand(stdout, stderr io.Writer) *cobra.Command {
|
|||||||
Short: "Scan / with the default excludes, then print the duplicate-tree report",
|
Short: "Scan / with the default excludes, then print the duplicate-tree report",
|
||||||
Args: cobra.NoArgs,
|
Args: cobra.NoArgs,
|
||||||
RunE: runE(func(ctx context.Context, _ []string) error {
|
RunE: runE(func(ctx context.Context, _ []string) error {
|
||||||
|
ctx, stop := interruptContext(ctx)
|
||||||
|
defer stop()
|
||||||
|
|
||||||
return runDwim(ctx, "/", stdout)
|
return runDwim(ctx, "/", stdout)
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user