Compare commits
No commits in common. "ed40673e8527490256d7d7acc90b952cb48571b6" and "d3776d7d7cc83798b8525e0dcb9277d1968efd82" have entirely different histories.
ed40673e85
...
d3776d7d7c
@ -363,10 +363,10 @@ The manifest file would do several important things:
|
||||
|
||||
## Lower Priority
|
||||
|
||||
- [x] **Add unit tests for `internal/checker`** - 88.5% coverage.
|
||||
- [x] **Add unit tests for `internal/scanner`** - 80.1% coverage.
|
||||
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem.
|
||||
- [x] **Validate input paths before scanning** - Fails fast with clear error if paths don't exist.
|
||||
- [ ] **Add unit tests for `internal/checker`** - Currently has no test files; only tested indirectly via CLI tests.
|
||||
- [ ] **Add unit tests for `internal/scanner`** - Currently has no test files.
|
||||
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem, avoid redundant stat calls.
|
||||
- [ ] **Validate input paths before scanning** - Should fail fast with a clear error if paths don't exist.
|
||||
|
||||
# Open Questions
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -65,10 +64,7 @@ func (m *manifest) addInputPath(inputPath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Validate path exists
|
||||
if _, err := os.Stat(abs); err != nil {
|
||||
return fmt.Errorf("path does not exist: %s", inputPath)
|
||||
}
|
||||
// FIXME check to make sure inputPath/abs exists maybe
|
||||
afs := afero.NewReadOnlyFs(afero.NewBasePathFs(afero.NewOsFs(), abs))
|
||||
return m.addInputFS(afs)
|
||||
}
|
||||
@ -160,25 +156,22 @@ func (m *manifest) addFile(p string, fi fs.FileInfo, sfsIndex int) error {
|
||||
if !m.scanOptions.IncludeDotfiles && pathIsHidden(p) {
|
||||
return nil
|
||||
}
|
||||
if fi == nil {
|
||||
// fi should come from Walk; if nil, stat to get info
|
||||
var err error
|
||||
fi, err = m.sourceFS[sfsIndex].Stat(p)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fi.IsDir() {
|
||||
if fi != nil && fi.IsDir() {
|
||||
// manifests contain only files, directories are implied.
|
||||
return nil
|
||||
}
|
||||
// FIXME test if 'fi' is already result of stat
|
||||
fileinfo, staterr := m.sourceFS[sfsIndex].Stat(p)
|
||||
if staterr != nil {
|
||||
return staterr
|
||||
}
|
||||
cleanPath := p
|
||||
if cleanPath[0:1] == "/" {
|
||||
cleanPath = cleanPath[1:]
|
||||
}
|
||||
nf := &manifestFile{
|
||||
path: cleanPath,
|
||||
info: fi,
|
||||
info: fileinfo,
|
||||
}
|
||||
m.files = append(m.files, nf)
|
||||
m.totalFileSize = m.totalFileSize + fi.Size()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user