Commit 6787bc78 authored by Steven Allen's avatar Steven Allen

fix: skip non-directories

parent 862f5340
...@@ -728,16 +728,20 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) { ...@@ -728,16 +728,20 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) {
} }
func (fs *Datastore) walkTopLevel(path string, result *query.ResultBuilder) error { func (fs *Datastore) walkTopLevel(path string, result *query.ResultBuilder) error {
dir, err := open(path) dir, err := os.Open(path)
if err != nil { if err != nil {
return err return err
} }
defer dir.Close() defer dir.Close()
names, err := dir.Readdirnames(-1) entries, err := dir.Readdir(-1)
if err != nil { if err != nil {
return err return err
} }
for _, dir := range names { for _, entry := range entries {
if !entry.IsDir() {
continue
}
dir := entry.Name()
if len(dir) == 0 || dir[0] == '.' { if len(dir) == 0 || dir[0] == '.' {
continue continue
} }
...@@ -1053,8 +1057,9 @@ func (fs *Datastore) tempFile() (*os.File, error) { ...@@ -1053,8 +1057,9 @@ func (fs *Datastore) tempFile() (*os.File, error) {
return file, err return file, err
} }
// only call this on directories.
func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error { func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error {
dir, err := open(path) dir, err := os.Open(path)
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
// not an error if the file disappeared // not an error if the file disappeared
...@@ -1064,15 +1069,6 @@ func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error { ...@@ -1064,15 +1069,6 @@ func (fs *Datastore) walk(path string, qrb *query.ResultBuilder) error {
} }
defer dir.Close() defer dir.Close()
// ignore non-directories
fileInfo, err := dir.Stat()
if err != nil {
return err
}
if !fileInfo.IsDir() {
return nil
}
names, err := dir.Readdirnames(-1) names, err := dir.Readdirnames(-1)
if err != nil { if err != nil {
return err return err
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment