mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2024-12-26 06:52:18 -05:00
add check for existing symlink
Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
parent
434fb17078
commit
0dc6404f6a
1 changed files with 14 additions and 7 deletions
|
@ -223,7 +223,7 @@ async function cacheWindowsDir(
|
||||||
}
|
}
|
||||||
|
|
||||||
core.info(`Found Cache Directory Paths: ${cacheDirectoryPaths}`);
|
core.info(`Found Cache Directory Paths: ${cacheDirectoryPaths}`);
|
||||||
|
|
||||||
// replace cache directory path with actual cache directory path
|
// replace cache directory path with actual cache directory path
|
||||||
const actualCacheDirectoryPaths = cacheDirectoryPaths.map(path => {
|
const actualCacheDirectoryPaths = cacheDirectoryPaths.map(path => {
|
||||||
return {
|
return {
|
||||||
|
@ -232,17 +232,24 @@ async function cacheWindowsDir(
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// iterate through actual cache directory paths and make links
|
// iterate through actual cache directory paths and make links if necessary
|
||||||
for (const cachePath of actualCacheDirectoryPaths) {
|
for (const cachePath of actualCacheDirectoryPaths) {
|
||||||
if (!fs.existsSync(cachePath.actualPath)) {
|
if (!fs.existsSync(cachePath.actualPath)) {
|
||||||
core.info(`Creating directory ${cachePath.actualPath}`);
|
core.info(`Creating directory ${cachePath.actualPath}`);
|
||||||
fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true});
|
fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true});
|
||||||
|
} else {
|
||||||
|
core.info(`Directory ${cachePath.actualPath} already exists`);
|
||||||
|
// make sure the link is pointing to the actual cache directory
|
||||||
|
let symlinkTarget = fs.readlinkSync(cachePath.defaultPath);
|
||||||
|
if (symlinkTarget !== "") {
|
||||||
|
core.info(`Found link ${cachePath.defaultPath} => ${symlinkTarget}`);
|
||||||
|
} else {
|
||||||
|
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
|
||||||
|
core.info(
|
||||||
|
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
|
|
||||||
core.info(
|
|
||||||
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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:
|
||||||
|
|
Loading…
Reference in a new issue