SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
avoid possible nil reader
Chris Lu9bcb28a3eabc
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.goindex 6225ab9683..5701b92b7a 100644--- a/weed/filesys/filehandle.go+++ b/weed/filesys/filehandle.go@@ -126,12 +126,14 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {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)- 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 {glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err)