Skip to content

Commit

Permalink
fix(gatsby-source-filesystem): Do not re-download cached files from c…
Browse files Browse the repository at this point in the history
…reateRemoteFileNode (#12054)

* Correct headers option for got() in createRemoteFileNode.

* Only encache response headers for success responses.
  • Loading branch information
skinandbones authored and sidharthachatterjee committed Feb 25, 2019
1 parent 0cddae3 commit a358239
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async function pushToQueue(task, cb) {
const requestRemoteNode = (url, headers, tmpFilename) =>
new Promise((resolve, reject) => {
const responseStream = got.stream(url, {
...headers,
headers,
timeout: 30000,
retries: 5,
})
Expand Down Expand Up @@ -225,8 +225,11 @@ async function processRemoteNode({

// Fetch the file.
const response = await requestRemoteNode(url, headers, tmpFilename)
// Save the response headers for future requests.
await cache.set(cacheId(url), response.headers)

if (response.statusCode == 200) {
// Save the response headers for future requests.
await cache.set(cacheId(url), response.headers)
}

// If the user did not provide an extension and we couldn't get one from remote file, try and guess one
if (ext === ``) {
Expand Down

0 comments on commit a358239

Please sign in to comment.