rename lnkSrc

This commit is contained in:
Sergey Dolin 2023-07-17 14:42:22 +02:00
parent 90cd2f950f
commit 00f551b2d1
2 changed files with 24 additions and 14 deletions

18
dist/setup/index.js vendored
View file

@ -61468,8 +61468,12 @@ function installGoVersion(info, auth, arch) {
// by avoiding write operations to C: // by avoiding write operations to C:
const isHosted = process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' || const isHosted = process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
process.env['AGENT_ISSELFHOSTED'] === '0'; process.env['AGENT_ISSELFHOSTED'] === '0';
if (isWindows && isHosted && fs_1.default.existsSync('d:\\') && fs_1.default.existsSync('c:\\')) { const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'] || ''; if (isWindows &&
defaultToolCacheRoot &&
isHosted &&
fs_1.default.existsSync('d:\\') &&
fs_1.default.existsSync('c:\\')) {
const substitutedToolCacheRoot = defaultToolCacheRoot const substitutedToolCacheRoot = defaultToolCacheRoot
.replace('C:', 'D:') .replace('C:', 'D:')
.replace('c:', 'd:'); .replace('c:', 'd:');
@ -61477,14 +61481,14 @@ function installGoVersion(info, auth, arch) {
process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot; process.env['RUNNER_TOOL_CACHE'] = substitutedToolCacheRoot;
const actualToolCacheDir = yield addExecutablesToCache(extPath, info, arch); const actualToolCacheDir = yield addExecutablesToCache(extPath, info, arch);
// create a link from c: to d: // create a link from c: to d:
const lnkSrc = actualToolCacheDir.replace(substitutedToolCacheRoot, defaultToolCacheRoot); const defaultToolCacheDir = actualToolCacheDir.replace(substitutedToolCacheRoot, defaultToolCacheRoot);
fs_1.default.mkdirSync(path.dirname(lnkSrc), { recursive: true }); fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
fs_1.default.symlinkSync(actualToolCacheDir, lnkSrc, 'junction'); fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
core.info(`Created link ${lnkSrc} => ${actualToolCacheDir}`); core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
// restore toolcache root to default drive c: // restore toolcache root to default drive c:
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot; process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
// make outer code to continue using toolcache as if it were installed on c: // make outer code to continue using toolcache as if it were installed on c:
return lnkSrc; return defaultToolCacheDir;
} }
return yield addExecutablesToCache(extPath, info, arch); return yield addExecutablesToCache(extPath, info, arch);
}); });

View file

@ -206,8 +206,14 @@ async function installGoVersion(
const isHosted = const isHosted =
process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' || process.env['RUNNER_ENVIRONMENT'] === 'github-hosted' ||
process.env['AGENT_ISSELFHOSTED'] === '0'; process.env['AGENT_ISSELFHOSTED'] === '0';
if (isWindows && isHosted && fs.existsSync('d:\\') && fs.existsSync('c:\\')) { const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'] || ''; if (
isWindows &&
defaultToolCacheRoot &&
isHosted &&
fs.existsSync('d:\\') &&
fs.existsSync('c:\\')
) {
const substitutedToolCacheRoot = defaultToolCacheRoot const substitutedToolCacheRoot = defaultToolCacheRoot
.replace('C:', 'D:') .replace('C:', 'D:')
.replace('c:', 'd:'); .replace('c:', 'd:');
@ -217,19 +223,19 @@ async function installGoVersion(
const actualToolCacheDir = await addExecutablesToCache(extPath, info, arch); const actualToolCacheDir = await addExecutablesToCache(extPath, info, arch);
// create a link from c: to d: // create a link from c: to d:
const lnkSrc = actualToolCacheDir.replace( const defaultToolCacheDir = actualToolCacheDir.replace(
substitutedToolCacheRoot, substitutedToolCacheRoot,
defaultToolCacheRoot defaultToolCacheRoot
); );
fs.mkdirSync(path.dirname(lnkSrc), {recursive: true}); fs.mkdirSync(path.dirname(defaultToolCacheDir), {recursive: true});
fs.symlinkSync(actualToolCacheDir, lnkSrc, 'junction'); fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
core.info(`Created link ${lnkSrc} => ${actualToolCacheDir}`); core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
// restore toolcache root to default drive c: // restore toolcache root to default drive c:
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot; process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;
// make outer code to continue using toolcache as if it were installed on c: // make outer code to continue using toolcache as if it were installed on c:
return lnkSrc; return defaultToolCacheDir;
} }
return await addExecutablesToCache(extPath, info, arch); return await addExecutablesToCache(extPath, info, arch);