Skip to content

Commit

Permalink
Fix GridFS ErrWrongSize error for big files
Browse files Browse the repository at this point in the history
GODRIVER-1012

Change-Id: I695f6f08cf5e5bded9a6e4bcd36eff46d5e30742
  • Loading branch information
eppingere committed Jun 4, 2019
1 parent 9c768d7 commit ff04022
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mongo/gridfs/download_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import (

"errors"

"time"

"io"
"math"
"time"

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

if int64(bytesLen) != bytesRemaining {
Expand Down

0 comments on commit ff04022

Please sign in to comment.