Fix ReadAt

This commit is contained in:
Quentin 2021-11-20 10:03:16 +01:00
parent 4448577ec1
commit 87fff9843d

View file

@ -86,7 +86,10 @@ func (f *S3File) Read(p []byte) (n int, err error) {
} }
func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) { func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) {
if f.eof { stat, err := f.Stat()
if err != nil {
return 0, err
} else if off >= stat.Size() {
return 0, io.EOF return 0, io.EOF
} }
@ -95,10 +98,7 @@ func (f *S3File) ReadAt(p []byte, off int64) (n int, err error) {
return 0, err return 0, err
} }
n, err = f.obj.ReadAt(p, off) return f.obj.ReadAt(p, off)
f.eof = err == io.EOF
return
} }
func (f *S3File) WriteAt(p []byte, off int64) (n int, err error) { func (f *S3File) WriteAt(p []byte, off int64) (n int, err error) {