diff --git a/dist/setup/index.js b/dist/setup/index.js index c8becb4..af35fb6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -88402,12 +88402,17 @@ function cacheWindowsDir(extPath, tool, version, arch) { for (const cachePath of actualCacheDirectoryPaths) { core.info(`Trying to link ${cachePath.defaultPath} to ${cachePath.actualPath}`); try { + if (!fs_1.default.existsSync(cachePath.defaultPath)) { + core.info(`Default path ${cachePath.defaultPath} does not exist`); + core.info(`Creating directory ${cachePath.defaultPath}`); + fs_1.default.mkdirSync(cachePath.defaultPath, { recursive: true }); + } if (!fs_1.default.existsSync(cachePath.actualPath)) { - core.info(`Creating directory ${cachePath.actualPath}`); - fs_1.default.mkdirSync(path.dirname(cachePath.actualPath), { recursive: true }); + core.info(`Actual path ${cachePath.actualPath} does not exist. Safe to create symlink`); } else { - core.info(`Directory ${cachePath.actualPath} already exists`); + core.info(`Actual path ${cachePath.actualPath} already exists. Skipping symlink creation`); + continue; } // check if the default path is a symlink const isSymlink = fs_1.default.lstatSync(cachePath.defaultPath).isSymbolicLink(); diff --git a/src/installer.ts b/src/installer.ts index 0554c17..235a640 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -236,11 +236,16 @@ async function cacheWindowsDir( for (const cachePath of actualCacheDirectoryPaths) { core.info(`Trying to link ${cachePath.defaultPath} to ${cachePath.actualPath}`); try { + if (!fs.existsSync(cachePath.defaultPath)) { + core.info(`Default path ${cachePath.defaultPath} does not exist`); + core.info(`Creating directory ${cachePath.defaultPath}`); + fs.mkdirSync(cachePath.defaultPath, {recursive: true}); + } if (!fs.existsSync(cachePath.actualPath)) { - core.info(`Creating directory ${cachePath.actualPath}`); - fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true}); + core.info(`Actual path ${cachePath.actualPath} does not exist. Safe to create symlink`); } else { - core.info(`Directory ${cachePath.actualPath} already exists`); + core.info(`Actual path ${cachePath.actualPath} already exists. Skipping symlink creation`); + continue; } // check if the default path is a symlink