Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-source-filesystem): Do not re-download cached files from createRemoteFileNode #12054

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to handle any other successful response status codes? Like 201 etc

I noticed that we also check for only 200 later in the file when moving temp data over so I'd guess we should be okay.

// 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