Keep going past unreadable files with check --continue (closes #11)
check / check (push) Successful in 2m1s
check / check (push) Successful in 2m1s
With --continue, check stopped at the first file whose content or checksum attribute it could not read, and at the first directory it could not list. Each of these now counts as failed, its error, which names the path, goes to stderr, and the walk goes on; the run still exits non-zero. The count that sizes the progress bar leaves such a path out, so the bar stays. The walk and the count, shared with sum and clear, take the continue setting; those commands pass false and still stop at the first error. Without --continue the first such error still stops the run, and the summary printed before it now counts an unreadable checksum attribute as failed, as it already did for unreadable content. Model: opus-5-5
This commit was merged in pull request #15.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -271,3 +272,59 @@ func TestPermissionErrors(t *testing.T) {
|
||||
t.Fatalf("expected permission error on check, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckContinuePastUnreadable(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
opts := &options{}
|
||||
dir := t.TempDir()
|
||||
skipIfNoXattr(t, dir)
|
||||
|
||||
writeFile(t, dir, "a.txt", "one")
|
||||
secret := writeFile(t, dir, "b.txt", "two")
|
||||
writeFile(t, dir, "c/d.txt", "three")
|
||||
writeFile(t, dir, "e.txt", "four")
|
||||
|
||||
err := processSumAdd(opts, dir, newTestStats(), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("add: %v", err)
|
||||
}
|
||||
|
||||
// An unreadable file and an unlistable directory sit between the
|
||||
// readable files a.txt and e.txt.
|
||||
sub := filepath.Join(dir, "c")
|
||||
|
||||
err = os.Chmod(secret, noPerm)
|
||||
if err != nil {
|
||||
t.Fatalf("chmod file: %v", err)
|
||||
}
|
||||
|
||||
defer func() { _ = os.Chmod(secret, filePerm) }()
|
||||
|
||||
err = os.Chmod(sub, noPerm)
|
||||
if err != nil {
|
||||
t.Fatalf("chmod dir: %v", err)
|
||||
}
|
||||
|
||||
defer func() { _ = os.Chmod(sub, dirPerm) }()
|
||||
|
||||
stats := newTestStats()
|
||||
|
||||
err = processCheck(opts, dir, true, stats, nil)
|
||||
if !errors.Is(err, errVerification) {
|
||||
t.Fatalf("expected verification error, got %v", err)
|
||||
}
|
||||
|
||||
if stats.FilesProcessed != 2 || stats.FilesFailed != 2 {
|
||||
t.Fatalf("expected 2 verified and 2 failed, got %d and %d",
|
||||
stats.FilesProcessed, stats.FilesFailed)
|
||||
}
|
||||
|
||||
// Without --quiet, runCheck counts the files for the progress bar
|
||||
// before it checks any, so the count reaches the unlistable directory
|
||||
// first.
|
||||
err = runCheck(opts, []string{dir}, true)
|
||||
if !errors.Is(err, errVerification) {
|
||||
t.Fatalf("expected verification error from runCheck, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user