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) {
defer close(reschan)
err := fs.walkTopLevel(fs.path, reschan)
if err != nil {
log.Warning("walk failed: ", err)
reschan <- query.Result{Error: errors.New("walk failed: " + err.Error())}
}
}()
return query.ResultsWithChan(q, reschan), nil
......@@ -357,6 +357,16 @@ func (fs *Datastore) walk(path string, reschan chan query.Result) error {
return err
}
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)
if err != nil {
return err
......
......@@ -343,6 +343,11 @@ func testQuerySimple(dirFunc mkShardFunc, t *testing.T) {
temp, cleanup := tempdir(t)
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)
if err != nil {
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