bashing through usecases and updating tests as we go.

so many things that can go wrong. have to catch them all.

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-10-19 15:18:33 -04:00
parent 054103b733
commit b295e8fd5c
11 changed files with 404 additions and 181 deletions

View File

@@ -17,6 +17,7 @@ import (
)
type LocalFS struct {
indexConfig *SpecIndexConfig
entryPointDirectory string
baseDirectory string
Files map[string]RolodexFile
@@ -28,7 +29,18 @@ func (l *LocalFS) GetFiles() map[string]RolodexFile {
return l.Files
}
func (l *LocalFS) GetErrors() []error {
return l.readingErrors
}
func (l *LocalFS) Open(name string) (fs.File, error) {
if l.indexConfig != nil && !l.indexConfig.AllowFileLookup {
return nil, &fs.PathError{Op: "open", Path: name,
Err: fmt.Errorf("file lookup for '%s' not allowed, set the index configuration "+
"to AllowFileLookup to be true", name)}
}
if !filepath.IsAbs(name) {
var absErr error
name, absErr = filepath.Abs(filepath.Join(l.baseDirectory, name))