mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2024-12-26 23:12:21 -05:00
wrap with try, debugging errors
Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
parent
896e2cbf0f
commit
c8eefa5dde
1 changed files with 22 additions and 16 deletions
|
@ -235,23 +235,29 @@ async function cacheWindowsDir(
|
||||||
// iterate through actual cache directory paths and make links if necessary
|
// iterate through actual cache directory paths and make links if necessary
|
||||||
for (const cachePath of actualCacheDirectoryPaths) {
|
for (const cachePath of actualCacheDirectoryPaths) {
|
||||||
core.info(`Trying to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
core.info(`Trying to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
||||||
|
try {
|
||||||
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 {
|
} else {
|
||||||
core.info(`Directory ${cachePath.actualPath} already exists`);
|
core.info(`Directory ${cachePath.actualPath} already exists`);
|
||||||
}
|
}
|
||||||
// make sure the link is pointing to the actual cache directory
|
|
||||||
const symlinkTarget = fs.readlinkSync(cachePath.defaultPath);
|
// check if the default path is a symlink
|
||||||
core.info(`Symlink target: ${symlinkTarget}`);
|
const isSymlink = fs.lstatSync(cachePath.defaultPath).isSymbolicLink();
|
||||||
if (symlinkTarget !== "") {
|
if (isSymlink) {
|
||||||
core.info(`Found link ${cachePath.defaultPath} => ${symlinkTarget}`);
|
core.info(`Default path is symlink ${cachePath.defaultPath} => ${fs.readlinkSync(cachePath.defaultPath)}`);
|
||||||
} else {
|
} else {
|
||||||
|
core.info(`Default path is not a symlink ${cachePath.defaultPath}`);
|
||||||
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
|
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
|
||||||
core.info(
|
core.info(
|
||||||
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
|
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
core.info(`Failed to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
||||||
|
core.info('Error: ' + err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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