Keep going past unreadable files with check --continue (closes #11)
check / check (push) Successful in 3m59s

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 walk shared with sum and clear takes the continue
setting, and they pass false. If the count that sizes the progress bar
cannot read a path, check --continue runs without the bar. 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 is contained in:
2026-10-06 00:56:34 +00:00
committed by sneak
parent 6a0dfa9f2c
commit a1764c17df
3 changed files with 78 additions and 10 deletions
+49
View File
@@ -1,6 +1,7 @@
package main
import (
"errors"
"os"
"path/filepath"
"strings"
@@ -271,3 +272,51 @@ 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)
}
}