fix: possible upload stream starting early

This commit is contained in:
Bobby 2022-09-24 06:41:31 +07:00
parent 518b29c8df
commit a646d6731a
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -432,6 +432,8 @@ self.actuallyUpload = async (req, res, data = {}) => {
if (hashStream) {
hashStream.once('error', _reject)
// Ensure readStream will only be resumed later down the line by readStream.pipe()
readStream.pause()
readStream.on('data', data => {
// .dispose() will destroy this internal component,
// so use it as an indicator of whether the hashStream has been .dispose()'d