andrewrk / node-s3-client

high level amazon s3 client for node.js
MIT License
1k stars 303 forks source link

End Sync Only When Transfers Have Ended #130

Closed dvalentiate closed 8 years ago

dvalentiate commented 8 years ago

Currently uploadDir method fails because it doesn't wait for individual upload steams to end before emitting the end event. It does wait until the total data sent reaches the expected amount but this happens before the files are reliably on S3 and the end event for each file occurs.

This pull request adds a activeTransfer counter that increments with a new file being uploaded and decrements when the file has an end event.

It also adds a test that fails on the current master but passes with these changes. Tested on node v0.10.35, v0.12.7, v4.3.2, and v5.7.1.

faceleg commented 8 years ago

I don't use this, but I'm happy to merge!

bradgreens commented 8 years ago

Is this merged updated end event included in the 4.4.0 npm release? I am observing the end event firing too early with 4.4.0 installed. I see I'm on node 5.6.0 and that wasn't explicitly tested here.