diff --git a/internal/fs/file.go b/internal/fs/file.go index 8885a32..246baff 100644 --- a/internal/fs/file.go +++ b/internal/fs/file.go @@ -375,6 +375,9 @@ func (f *File) Readdir(count int) ([]os.FileInfo, error) { f.ioLock.Lock() defer f.ioLock.Unlock() + if !f.info.IsDir() { + return []os.FileInfo{}, config.ErrIsFile + } hdrs, err := inventory.List( f.metadata, @@ -401,6 +404,10 @@ func (f *File) Readdirnames(n int) ([]string, error) { "n": n, }) + if !f.info.IsDir() { + return []string{}, config.ErrIsFile + } + dirs, err := f.Readdir(n) if err != nil { return []string{}, err diff --git a/pkg/config/error.go b/pkg/config/error.go index 01be43d..01be115 100644 --- a/pkg/config/error.go +++ b/pkg/config/error.go @@ -35,6 +35,7 @@ var ( ErrNotImplemented = errors.New("not implemented") ErrIsDirectory = errors.New("is a directory") + ErrIsFile = errors.New("is a file") ErrFileSystemCacheTypeUnsupported = errors.New("file system cache type unsupported") ErrFileSystemCacheTypeUnknown = errors.New("file system cache type unknown")