fix: FindExtraFiles skips dotfiles and manifest files to avoid false positives

FindExtraFiles now skips hidden files/directories and manifest files
(index.mf, .index.mf) when looking for extra files. Previously it would
report these as 'extra' even though they are intentionally excluded from
manifests by default, making --no-extra-files unusable.

Also includes IsHiddenPath fix for '.' (needed by the new filtering).
This commit is contained in:
clawbot
2026-02-08 12:06:08 -08:00
parent 4b80c0067b
commit ce2540d7e1
4 changed files with 84 additions and 10 deletions

View File

@@ -227,12 +227,14 @@ func (c *Checker) checkFile(entry *mfer.MFFilePath, checkedBytes *int64) Result
// FindExtraFiles walks the filesystem and reports files not in the manifest.
// Results are sent to the results channel. The channel is closed when done.
// Hidden files/directories (starting with .) are skipped, as they are excluded
// from manifests by default. The manifest file itself is also skipped.
func (c *Checker) FindExtraFiles(ctx context.Context, results chan<- Result) error {
if results != nil {
defer close(results)
}
return afero.Walk(c.fs, c.basePath, func(path string, info os.FileInfo, err error) error {
return afero.Walk(c.fs, c.basePath, func(walkPath string, info os.FileInfo, err error) error {
if err != nil {
return err
}
@@ -243,15 +245,29 @@ func (c *Checker) FindExtraFiles(ctx context.Context, results chan<- Result) err
default:
}
// Get relative path
relPath, err := filepath.Rel(c.basePath, walkPath)
if err != nil {
return err
}
// Skip hidden files and directories (dotfiles)
if mfer.IsHiddenPath(filepath.ToSlash(relPath)) {
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
// Skip directories
if info.IsDir() {
return nil
}
// Get relative path
relPath, err := filepath.Rel(c.basePath, path)
if err != nil {
return err
// Skip manifest files
base := filepath.Base(relPath)
if base == "index.mf" || base == ".index.mf" {
return nil
}
// Check if path is in manifest