commit 41e9b36e077197a90ca39be7223ea5f43f2ef455
parent 75d20bcd792dbee6682b653497ef542d582cfd28
Author: Matsuda Kenji <info@mtkn.jp>
Date: Sun, 7 Jan 2024 13:03:00 +0900
fix bug and follow the document of fs.ReadDir.
it must return nil error when n == -1 and readdir succeeds to read
to the end of that directory
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/client/file.go b/client/file.go
@@ -111,7 +111,6 @@ func (cf *File) ReadDir(n int) ([]fs.DirEntry, error) {
if err != nil {
break
} else if len(data) == 0 {
- err = io.EOF
break
}
cf.fid.offset += uint64(len(data))
@@ -128,5 +127,8 @@ func (cf *File) ReadDir(n int) ([]fs.DirEntry, error) {
de = cf.dirBuf
cf.dirBuf = nil
}
+ if err == nil && len(de) == 0 && n > 0 {
+ err = io.EOF
+ }
return de, err
}