Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always call fillQueue #36

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/s3/managed_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ AWS.S3.ManagedUpload = AWS.util.inherit({
on('end', function() {
self.isDoneChunking = true;
self.numParts = self.totalPartNumbers;
self.fillQueue.call(self);
if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) {
self.finishMultiPart();
} else {
self.fillQueue.call(self);
}
});
}
Expand Down
29 changes: 29 additions & 0 deletions test/s3/managed_upload.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,35 @@ describe 'AWS.S3.ManagedUpload', ->
]
done()

it 'can send a stream that is larger then the part size', (done) ->
partSize = 5 * 1024 * 1024
streamSize = 1024 + partSize
require('crypto').randomBytes streamSize, (err, buf) ->
return done(err) if err

stream = AWS.util.buffer.toStream buf
reqs = helpers.mockResponses [
{ data: UploadId: 'uploadId' }
{ data: ETag: 'ETAG1' }
{ data: ETag: 'ETAG2' }
{ data: ETag: 'FINAL_ETAG', Location: 'FINAL_LOCATION' }
]
upload = new AWS.S3.ManagedUpload({
partSize: partSize,
queueSize: 1,
params: { Body: stream }
})
upload.send (err) ->
return done(err) if err

expect(helpers.operationsForRequests(reqs)).to.eql [
's3.createMultipartUpload',
's3.uploadPart',
's3.uploadPart',
's3.completeMultipartUpload'
]
done()

it 'can send a stream that is exactly divisible by part size', (done) ->
partSize = 5 * 1024 * 1024
streamSize = 2 * partSize
Expand Down