Skip to content

Commit

Permalink
fix bug in got
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Aug 27, 2021
1 parent 611e14a commit ef20b74
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/gatsby-core-utils/src/fetch-remote-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ const requestRemoteNode = (
})

let haveAllBytesBeenWritten = false
let totalSize = null
responseStream.on(`downloadProgress`, progress => {
if (
progress.transferred === progress.total ||
progress.total === null ||
progress.total === undefined
) {
if (progress.total != null && !totalSize) {
totalSize = progress.total
}

if (progress.transferred === totalSize || totalSize === null) {
haveAllBytesBeenWritten = true
}
})
Expand Down Expand Up @@ -132,7 +133,6 @@ const requestRemoteNode = (

fsWriteStream.on(`finish`, () => {
fsWriteStream.close()

// We have an incomplete download
if (!haveAllBytesBeenWritten) {
fs.removeSync(tmpFilename)
Expand Down

0 comments on commit ef20b74

Please sign in to comment.