Closed weberc2-tempus closed 10 months ago
EDIT: Oops, filed this against src-d/go-billy instead of go-git/go-billy. Re-filed issue here
v5.4.1
memfs.New().ReadDir("asdf") returns nil, nil instead of nil, <directory-not-found-err>.
memfs.New().ReadDir("asdf")
nil, nil
nil, <directory-not-found-err>
func TestMemoryReadDir(t *testing.T) { if _, err := osfs.New("/tmp").ReadDir("asdf"); err == nil { t.Fatal("osfs: expected error; found <nil>") } else { t.Logf("osfs: error was correctly returned!") } if _, err := memfs.New().ReadDir("asdf"); err == nil { t.Fatal("memfs: expected error; found <nil>") } else { t.Logf("memfs: error was correctly returned!") } } // Output // osfs: error was correctly returned! // memfs: expected error; found <nil>
func (fs *Memory) ReadDir(path string) ([]os.FileInfo, error) { if f, has := fs.s.Get(path); has { if target, isLink := fs.resolveLink(path, f); isLink { return fs.ReadDir(target) } + } else { + return nil, &fs.PathError{Op: "open", Path: path, Err: unix.ENOENT} } var entries []os.FileInfo for _, f := range fs.s.Children(path) { fi, _ := f.Stat() entries = append(entries, fi) } sort.Sort(ByName(entries)) return entries, nil }
Oops, filed this against src-d/go-billy instead of go-git/go-billy. Re-filed issue here
EDIT: Oops, filed this against src-d/go-billy instead of go-git/go-billy. Re-filed issue here
Version
v5.4.1
Description
memfs.New().ReadDir("asdf")
returnsnil, nil
instead ofnil, <directory-not-found-err>
.Minimal example
Proposed changes