Filter out EOF errors in ReadFile.
parent
bf0b773894
commit
f412eaa60a
|
@ -694,7 +694,8 @@ type ReadFileRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ReadFileResponse struct {
|
type ReadFileResponse struct {
|
||||||
// The data read.
|
// The data read. If this is less than the requested size, it indicates EOF.
|
||||||
|
// An error should not be returned in this case.
|
||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ package memfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -497,6 +498,11 @@ func (fs *memFS) ReadFile(
|
||||||
n, err := inode.ReadAt(resp.Data, req.Offset)
|
n, err := inode.ReadAt(resp.Data, req.Offset)
|
||||||
resp.Data = resp.Data[:n]
|
resp.Data = resp.Data[:n]
|
||||||
|
|
||||||
|
// Don't return EOF errors; we just indicate EOF to fuse using a short read.
|
||||||
|
if err == io.EOF {
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue