Compare commits
3 Commits
d3776d7d7c
...
ed40673e85
| Author | SHA1 | Date | |
|---|---|---|---|
| ed40673e85 | |||
| 2549695ab0 | |||
| e480c3f677 |
@ -363,10 +363,10 @@ The manifest file would do several important things:
|
|||||||
|
|
||||||
## Lower Priority
|
## Lower Priority
|
||||||
|
|
||||||
- [ ] **Add unit tests for `internal/checker`** - Currently has no test files; only tested indirectly via CLI tests.
|
- [x] **Add unit tests for `internal/checker`** - 88.5% coverage.
|
||||||
- [ ] **Add unit tests for `internal/scanner`** - Currently has no test files.
|
- [x] **Add unit tests for `internal/scanner`** - 80.1% coverage.
|
||||||
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem, avoid redundant stat calls.
|
- [ ] **Clean up FIXMEs in manifest.go** - Validate input paths exist, validate filesystem.
|
||||||
- [ ] **Validate input paths before scanning** - Should fail fast with a clear error if paths don't exist.
|
- [x] **Validate input paths before scanning** - Fails fast with clear error if paths don't exist.
|
||||||
|
|
||||||
# Open Questions
|
# Open Questions
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -64,7 +65,10 @@ func (m *manifest) addInputPath(inputPath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// FIXME check to make sure inputPath/abs exists maybe
|
// Validate path exists
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
@ -156,22 +160,25 @@ 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 && fi.IsDir() {
|
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() {
|
||||||
// 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: fileinfo,
|
info: fi,
|
||||||
}
|
}
|
||||||
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