Skip to content

Commit a358239

Browse files
skinandbonessidharthachatterjee
authored andcommitted
fix(gatsby-source-filesystem): Do not re-download cached files from createRemoteFileNode (#12054)
* Correct headers option for got() in createRemoteFileNode. * Only encache response headers for success responses.
1 parent 0cddae3 commit a358239

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/gatsby-source-filesystem/src/create-remote-file-node.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async function pushToQueue(task, cb) {
145145
const requestRemoteNode = (url, headers, tmpFilename) =>
146146
new Promise((resolve, reject) => {
147147
const responseStream = got.stream(url, {
148-
...headers,
148+
headers,
149149
timeout: 30000,
150150
retries: 5,
151151
})
@@ -225,8 +225,11 @@ async function processRemoteNode({
225225

226226
// Fetch the file.
227227
const response = await requestRemoteNode(url, headers, tmpFilename)
228-
// Save the response headers for future requests.
229-
await cache.set(cacheId(url), response.headers)
228+
229+
if (response.statusCode == 200) {
230+
// Save the response headers for future requests.
231+
await cache.set(cacheId(url), response.headers)
232+
}
230233

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

0 commit comments

Comments
 (0)