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
|
## Lower Priority
|
||||||
|
|
||||||
- [x] **Add unit tests for `internal/checker`** - 88.5% coverage.
|
- [ ] **Add unit tests for `internal/checker`** - Currently has no test files; only tested indirectly via CLI tests.
|
||||||
- [x] **Add unit tests for `internal/scanner`** - 80.1% coverage.
|
- [ ] **Add unit tests for `internal/scanner`** - Currently has no test files.
|
||||||
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem.
|
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem, avoid redundant stat calls.
|
||||||
- [x] **Validate input paths before scanning** - Fails fast with clear error if paths don't exist.
|
- [ ] **Validate input paths before scanning** - Should fail fast with a clear error if paths don't exist.
|
||||||
|
|
||||||
# Open Questions
|
# Open Questions
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -65,10 +64,7 @@ func (m *manifest) addInputPath(inputPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Validate path exists
|
// FIXME check to make sure inputPath/abs exists maybe
|
||||||
if _, err := os.Stat(abs); err != nil {
|
|
||||||
return fmt.Errorf("path does not exist: %s", inputPath)
|
|
||||||
}
|
|
||||||
afs := afero.NewReadOnlyFs(afero.NewBasePathFs(afero.NewOsFs(), abs))
|
afs := afero.NewReadOnlyFs(afero.NewBasePathFs(afero.NewOsFs(), abs))
|
||||||
return m.addInputFS(afs)
|
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) {
|
if !m.scanOptions.IncludeDotfiles && pathIsHidden(p) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if fi == nil {
|
if fi != nil && fi.IsDir() {
|
||||||
// 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() {
|
|
||||||
// manifests contain only files, directories are implied.
|
// manifests contain only files, directories are implied.
|
||||||
return nil
|
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
|
cleanPath := p
|
||||||
if cleanPath[0:1] == "/" {
|
if cleanPath[0:1] == "/" {
|
||||||
cleanPath = cleanPath[1:]
|
cleanPath = cleanPath[1:]
|
||||||
}
|
}
|
||||||
nf := &manifestFile{
|
nf := &manifestFile{
|
||||||
path: cleanPath,
|
path: cleanPath,
|
||||||
info: fi,
|
info: fileinfo,
|
||||||
}
|
}
|
||||||
m.files = append(m.files, nf)
|
m.files = append(m.files, nf)
|
||||||
m.totalFileSize = m.totalFileSize + fi.Size()
|
m.totalFileSize = m.totalFileSize + fi.Size()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user