richardgirges / express-fileupload

Simple express file upload middleware that wraps around busboy
MIT License
1.52k stars 261 forks source link

Have promiseCallback make callbacks and promises behave the same #302

Closed zwade closed 2 years ago

zwade commented 2 years ago

This PR addresses failing tests in test/fileFactory.spec.js. These tests were failing because an fsWriteStream was emitting both an error event and a close event that caused the callback to fire twice.

However, this only happened when using a the callback interface to file.mv, as the promise interface would naturally "eat" the second event. In order to both fix the tests, and ensure that both promises and callbacks behave the same way to the user, this PR adjusts the behavior of the promiseCallback wrapper function to prevent duplicate callbacks.

richardgirges commented 2 years ago

Thanks!