Commit 96522942 authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

Merge pull request #7 from ipfs/kevina/non-file-ignore

Ignore non-directories in the top level directory.
parents 3567e098 7ec19f16
...@@ -320,7 +320,7 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) { ...@@ -320,7 +320,7 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) {
defer close(reschan) defer close(reschan)
err := fs.walkTopLevel(fs.path, reschan) err := fs.walkTopLevel(fs.path, reschan)
if err != nil { if err != nil {
log.Warning("walk failed: ", err) reschan <- query.Result{Error: errors.New("walk failed: " + err.Error())}
} }
}() }()
return query.ResultsWithChan(q, reschan), nil return query.ResultsWithChan(q, reschan), nil
...@@ -357,6 +357,16 @@ func (fs *Datastore) walk(path string, reschan chan query.Result) error { ...@@ -357,6 +357,16 @@ func (fs *Datastore) walk(path string, reschan chan query.Result) error {
return err return err
} }
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
......
...@@ -343,6 +343,11 @@ func testQuerySimple(dirFunc mkShardFunc, t *testing.T) { ...@@ -343,6 +343,11 @@ func testQuerySimple(dirFunc mkShardFunc, t *testing.T) {
temp, cleanup := tempdir(t) temp, cleanup := tempdir(t)
defer cleanup() defer cleanup()
err := ioutil.WriteFile(filepath.Join(temp, "README"), []byte("something"), 0666)
if err != nil {
t.Fatalf("WriteFile fail: %v\n", err)
}
fs, err := flatfs.New(temp, dirFunc(2), false) fs, err := flatfs.New(temp, dirFunc(2), false)
if err != nil { if err != nil {
t.Fatalf("New fail: %v\n", err) t.Fatalf("New fail: %v\n", 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