mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
cloud tier: s3 consume all read response body
fix https://github.com/seaweedfs/seaweedfs/issues/3584
This commit is contained in:
parent
7c6324b114
commit
39340f7e42
|
@ -124,8 +124,6 @@ func (s3backendStorageFile S3BackendStorageFile) ReadAt(p []byte, off int64) (n
|
||||||
|
|
||||||
bytesRange := fmt.Sprintf("bytes=%d-%d", off, off+int64(len(p))-1)
|
bytesRange := fmt.Sprintf("bytes=%d-%d", off, off+int64(len(p))-1)
|
||||||
|
|
||||||
// glog.V(0).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
|
|
||||||
|
|
||||||
getObjectOutput, getObjectErr := s3backendStorageFile.backendStorage.conn.GetObject(&s3.GetObjectInput{
|
getObjectOutput, getObjectErr := s3backendStorageFile.backendStorage.conn.GetObject(&s3.GetObjectInput{
|
||||||
Bucket: &s3backendStorageFile.backendStorage.bucket,
|
Bucket: &s3backendStorageFile.backendStorage.bucket,
|
||||||
Key: &s3backendStorageFile.key,
|
Key: &s3backendStorageFile.key,
|
||||||
|
@ -137,13 +135,16 @@ func (s3backendStorageFile S3BackendStorageFile) ReadAt(p []byte, off int64) (n
|
||||||
}
|
}
|
||||||
defer getObjectOutput.Body.Close()
|
defer getObjectOutput.Body.Close()
|
||||||
|
|
||||||
glog.V(4).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
|
// glog.V(3).Infof("read %s %s", s3backendStorageFile.key, bytesRange)
|
||||||
glog.V(4).Infof("content range: %s, contentLength: %d", *getObjectOutput.ContentRange, *getObjectOutput.ContentLength)
|
// glog.V(3).Infof("content range: %s, contentLength: %d", *getObjectOutput.ContentRange, *getObjectOutput.ContentLength)
|
||||||
|
|
||||||
|
var readCount int
|
||||||
for {
|
for {
|
||||||
if n, err = getObjectOutput.Body.Read(p); err == nil && n < len(p) {
|
p = p[readCount:]
|
||||||
p = p[n:]
|
readCount, err = getObjectOutput.Body.Read(p)
|
||||||
} else {
|
n += readCount
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue