src: map file symlinks for old node versions#292
Merged
Conversation
flakey5
commented
Feb 10, 2025
Member
Author
There was a problem hiding this comment.
We're still well under the 10mb limit for a worker but since this file is only going to grow, I think we should continue looking at something like #159
ovflowd
reviewed
Feb 11, 2025
| // Let's add these to our cached directories. | ||
| const fileSymlinks = JSON.parse(await readFile(FILE_SYMLINKS, 'utf8')); | ||
|
|
||
| for (const file of Object.keys(fileSymlinks)) { |
Member
There was a problem hiding this comment.
Can this be cleaned up a bit? Maybe instead if else, we can have different loops just to separate concerns. Performance here should not be a driving factor.
Member
Author
There was a problem hiding this comment.
I'm not really sure separating it into two different loops would look much better,
for (const file of Object.keys(fileSymlinks)) {
const directory = `${dirname(file)}/`
if (!(directory in cachedDirectories)) {
continue;
}
const actualFile = await headFile(client, fileSymlinks[file]);
cachedDirectories[directory].files.push({
...actualFile,
name: basename(file)
})
}
for (const file of Object.keys(fileSymlinks)) {
const directory = `${dirname(file)}/`
if (!(directory in cachedDirectories)) {
continue;
}
const actualFile = await headFile(client, fileSymlinks[file]);
const contents = await listDirectory(client, directory);
contents.files.push({
...actualFile,
name: basename(file),
})
cachedDirectories[directory] = contents;
}
ovflowd
approved these changes
Feb 11, 2025
Signed-off-by: flakey5 <73616808+flakey5@users.noreply.github.com>
6b08c2e to
71edd3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Old Node versions have file symlinks pointing to them, but the worker wasn't handling this (i.e. for https://nodejs.org/dist/v0.1.99/ there should be a
node-v0.1.99.tar.gzfile but there's not).This:
fileSymlinks.jsonthat holds whatever files need symlinks. The key is the symlink location and the value is the actual location of the filebuild-r2-symlinks.jsscript readfileSymlinks.jsonand include them in the cached directory listings