mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid possible nil reader
fix https://github.com/chrislusf/seaweedfs/issues/1754
This commit is contained in:
parent
2c5eac5705
commit
9bcb28a3ea
|
@ -126,12 +126,14 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
|
||||||
fh.f.reader = nil
|
fh.f.reader = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if fh.f.reader == nil {
|
reader := fh.f.reader
|
||||||
|
if reader == nil {
|
||||||
chunkViews := filer.ViewFromVisibleIntervals(fh.f.entryViewCache, 0, math.MaxInt64)
|
chunkViews := filer.ViewFromVisibleIntervals(fh.f.entryViewCache, 0, math.MaxInt64)
|
||||||
fh.f.reader = filer.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache, fileSize)
|
reader = filer.NewChunkReaderAtFromClient(fh.f.wfs, chunkViews, fh.f.wfs.chunkCache, fileSize)
|
||||||
}
|
}
|
||||||
|
fh.f.reader = reader
|
||||||
|
|
||||||
totalRead, err := fh.f.reader.ReadAt(buff, offset)
|
totalRead, err := reader.ReadAt(buff, offset)
|
||||||
|
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err)
|
glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err)
|
||||||
|
|
Loading…
Reference in a new issue