@@ -3,6 +3,7 @@ import { basename, dirname } from 'node:path';
33import { S3Client } from '@aws-sdk/client-s3' ;
44import {
55 DOCS_DIR ,
6+ NODE_LATEST_FILE_NAME ,
67 PROD_BUCKET ,
78 RELEASE_DIR ,
89 STATIC_FILE_SYMLINKS_PATH ,
@@ -24,7 +25,7 @@ export async function addLatestTarSymlinkToCache(
2425 latestVersionMap ,
2526 latestVersion
2627) {
27- const nodeLatestPath = `${ RELEASE_DIR } ${ latestVersionMap [ 'node-latest.tar.gz' ] . replaceAll ( 'latest' , latestVersion ) } ` ;
28+ const nodeLatestPath = `${ RELEASE_DIR } ${ latestVersionMap [ NODE_LATEST_FILE_NAME ] . replaceAll ( 'latest' , latestVersion ) } ` ;
2829
2930 // Stat the file that `node-latest.tar.gz` points to so we can have accurate
3031 // size & last modified info for the directory listing. Also acts as a safety
@@ -37,7 +38,7 @@ export async function addLatestTarSymlinkToCache(
3738 }
3839
3940 releaseDirectory . files . push ( {
40- name : 'node-latest.tar.gz' ,
41+ name : NODE_LATEST_FILE_NAME ,
4142 lastModified : nodeLatest . lastModified ,
4243 size : nodeLatest . size ,
4344 } ) ;
@@ -54,7 +55,8 @@ export function addLatestDirectorySymlinksToCache(
5455) {
5556 releaseDirectory . subdirectories . push (
5657 ...Object . keys ( latestVersionMap )
57- . filter ( version => version !== 'node-latest.tar.gz' )
58+ // We only want directories, remove the only file in the map
59+ . filter ( version => version !== NODE_LATEST_FILE_NAME )
5860 . map ( version => `${ version } /` )
5961 ) ;
6062 releaseDirectory . subdirectories . sort ( ) ;
@@ -116,14 +118,20 @@ export async function addStaticFileSymlinksToCache(
116118 // TODO: remove when KV is considered stable
117119 const directoriesIncludedInFileCache = new Set ( [ RELEASE_DIR , DOCS_DIR ] ) ;
118120
121+ const fileSymlinksFile = await readFile ( STATIC_FILE_SYMLINKS_PATH , 'utf8' ) ;
122+
119123 /**
120124 * @type {Record<string, string> }
121125 */
122- const fileSymlinks = JSON . parse (
123- await readFile ( STATIC_FILE_SYMLINKS_PATH , 'utf8' )
124- ) ;
125-
126- // This isn't static, delete it for now
126+ const fileSymlinks = JSON . parse ( fileSymlinksFile ) ;
127+
128+ // This file is an exception for two reasons:
129+ // 1. It's dynamic and points to the latest Node version
130+ // 2. It's handled specially and is technically in the root directory,
131+ // which we should never be listing thus don't need to add it to the
132+ // directory cache.
133+ // So, let's remove it then add it back once we're done handling the rest of
134+ // the static file symlinks.
127135 fileSymlinks [ 'node-config-schema.json' ] = undefined ;
128136
129137 // Add the symlinks to the directory cache
0 commit comments