Skip to content

Commit

Permalink
fix: async callback run multiple times in fPutObject (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
nomagick committed Aug 3, 2022
1 parent 1dc5eb5 commit 728336b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/minio.js
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,15 @@ export class Client {
cb => fs.stat(filePath, cb),
(stats, cb) => {
size = stats.size
var cbTriggered = false
var origCb = cb
cb = function () {
if (cbTriggered) {
return
}
cbTriggered = true
return origCb.apply(this, arguments)
}
if (size > this.maxObjectSize) {
return cb(new Error(`${filePath} size : ${stats.size}, max allowed size : 5TB`))
}
Expand Down Expand Up @@ -1071,6 +1080,15 @@ export class Client {
async.whilst(
cb => { cb(null, uploadedSize < size) },
cb => {
var cbTriggered = false
var origCb = cb
cb = function () {
if (cbTriggered) {
return
}
cbTriggered = true
return origCb.apply(this, arguments)
}
var part = parts[partNumber]
var hash = transformers.getHashSummer(this.enableSHA256)
var length = partSize
Expand Down

0 comments on commit 728336b

Please sign in to comment.