aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/filehandle.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-08-16 00:49:08 -0700
committerChris Lu <chris.lu@gmail.com>2020-08-16 00:49:08 -0700
commitaec7f32b02c04aee315f67922cdb3813dbe7af72 (patch)
tree875d22d3b730efa409ad9e8a41331c155b10b099 /weed/filesys/filehandle.go
parent5d80fc2ec7b07aa6281eb7990f40552baed0df94 (diff)
downloadseaweedfs-aec7f32b02c04aee315f67922cdb3813dbe7af72.tar.xz
seaweedfs-aec7f32b02c04aee315f67922cdb3813dbe7af72.zip
fix reader_at
Diffstat (limited to 'weed/filesys/filehandle.go')
-rw-r--r--weed/filesys/filehandle.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 94029f61c..362013697 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -82,10 +82,11 @@ func (fh *FileHandle) readFromDirtyPages(buff []byte, startOffset int64) (offset
func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
- // this value should come from the filer instead of the old f
- if len(fh.f.entry.Chunks) == 0 {
+ fileSize := int64(filer2.FileSize(fh.f.entry))
+
+ if fileSize == 0 {
glog.V(1).Infof("empty fh %v", fh.f.fullpath())
- return 0, nil
+ return 0, io.EOF
}
var chunkResolveErr error
@@ -98,8 +99,9 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
}
if fh.f.reader == nil {
+ glog.V(1).Infof("entryViewCache %d", len(fh.f.entryViewCache))
chunkViews := filer2.ViewFromVisibleIntervals(fh.f.entryViewCache, 0, math.MaxInt32)
- fh.f.reader = filer2.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache)
+ fh.f.reader = filer2.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache, fileSize)
}
totalRead, err := fh.f.reader.ReadAt(buff, offset)