Skip to content

Commit ff04022

Browse files
committed
Fix GridFS ErrWrongSize error for big files
GODRIVER-1012 Change-Id: I695f6f08cf5e5bded9a6e4bcd36eff46d5e30742
1 parent 9c768d7 commit ff04022

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

mongo/gridfs/download_stream.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import (
1111

1212
"errors"
1313

14-
"time"
15-
1614
"io"
1715
"math"
16+
"time"
1817

1918
"go.mongodb.org/mongo-driver/mongo"
2019
)
@@ -188,7 +187,7 @@ func (ds *DownloadStream) fillBuffer(ctx context.Context) error {
188187
bytesLen := int32(len(dataBytes))
189188
if ds.expectedChunk == ds.numChunks {
190189
// final chunk can be fewer than ds.chunkSize bytes
191-
bytesDownloaded := ds.chunkSize * (ds.expectedChunk - 1)
190+
bytesDownloaded := int64(ds.chunkSize) * (int64(ds.expectedChunk) - int64(1))
192191
bytesRemaining := ds.fileLen - int64(bytesDownloaded)
193192

194193
if int64(bytesLen) != bytesRemaining {

0 commit comments

Comments
 (0)