From c0ab458671f2859990caab70b59041513d90edac Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 17 Oct 2020 11:03:46 -0700 Subject: [PATCH] report nil instead of EOF for empty files related to https://github.com/chrislusf/seaweedfs/issues/1541 --- weed/filesys/filehandle.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 01bca76f8..45abfcc5c 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -77,6 +77,10 @@ func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fus totalRead = max(maxStop-req.Offset, totalRead) } + if err == io.EOF { + err = nil + } + if err != nil { glog.Warningf("file handle read %s %d: %v", fh.f.fullpath(), totalRead, err) return fuse.EIO @@ -122,11 +126,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { totalRead, err := fh.f.reader.ReadAt(buff, offset) - if err == io.EOF { - err = nil - } - - if err != nil { + if err != nil && err != io.EOF{ glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err) }