fix: use os.ErrNotExist instead of errors.New() for file-not-found detection in checkers

errors.Is(err, errors.New("file does not exist")) can never match because
errors.New creates a unique value each time. Replace with os.ErrNotExist
which is the standard Go sentinel for file-not-found errors.

Fixes both mfer/checker.go and internal/checker/checker.go.
This commit is contained in:
clawbot
2026-02-08 12:02:31 -08:00
parent 4b80c0067b
commit 68fbebd0c5
3 changed files with 35 additions and 12 deletions

View File

@@ -174,12 +174,7 @@ func (c *Checker) checkFile(entry *mfer.MFFilePath, checkedBytes *int64) Result
// Check if file exists
info, err := c.fs.Stat(absPath)
if err != nil {
if errors.Is(err, afero.ErrFileNotFound) || errors.Is(err, errors.New("file does not exist")) {
return Result{Path: entry.Path, Status: StatusMissing, Message: "file not found"}
}
// Check for "file does not exist" style errors
exists, _ := afero.Exists(c.fs, absPath)
if !exists {
if errors.Is(err, os.ErrNotExist) || errors.Is(err, afero.ErrFileNotFound) {
return Result{Path: entry.Path, Status: StatusMissing, Message: "file not found"}
}
return Result{Path: entry.Path, Status: StatusError, Message: err.Error()}