mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2024-12-26 06:52:18 -05:00
fix
Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
parent
e3c077dd6d
commit
e91efc513b
1 changed files with 11 additions and 20 deletions
|
@ -236,29 +236,20 @@ async function cacheWindowsDir(
|
||||||
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 {
|
try {
|
||||||
if (!fs.existsSync(cachePath.defaultPath)) {
|
// the symlink already exists, skip
|
||||||
core.info(`Default path ${cachePath.defaultPath} does not exist`);
|
if (fs.existsSync(cachePath.defaultPath) && fs.lstatSync(cachePath.defaultPath).isSymbolicLink()) {
|
||||||
core.info(`Creating directory ${cachePath.defaultPath}`);
|
continue
|
||||||
fs.mkdirSync(cachePath.defaultPath, {recursive: true});
|
|
||||||
}
|
|
||||||
if (!fs.existsSync(cachePath.actualPath)) {
|
|
||||||
core.info(`Actual path ${cachePath.actualPath} does not exist. Safe to create symlink`);
|
|
||||||
} else {
|
|
||||||
core.info(`Actual path ${cachePath.actualPath} already exists. Skipping symlink creation`);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
// create a parent directory where the link will be created
|
||||||
|
fs.mkdirSync(path.dirname(cachePath.defaultPath), {recursive: true});
|
||||||
|
|
||||||
// check if the default path is a symlink
|
// create the target directory if it doesn't exist yet
|
||||||
const isSymlink = fs.lstatSync(cachePath.defaultPath).isSymbolicLink();
|
if (!fs.existsSync(cachePath.actualPath)) {
|
||||||
if (isSymlink) {
|
core.info(`Actual path ${cachePath.actualPath} does not exist. Creating`);
|
||||||
core.info(`Default path is symlink ${cachePath.defaultPath} => ${fs.readlinkSync(cachePath.defaultPath)}`);
|
fs.mkdirSync(cachePath.actualPath, {recursive: true});
|
||||||
} else {
|
|
||||||
core.info(`Default path is not a symlink ${cachePath.defaultPath}`);
|
|
||||||
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}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.info(`Failed to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
core.info(`Failed to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
||||||
core.info('Error: ' + err);
|
core.info('Error: ' + err);
|
||||||
|
|
Loading…
Reference in a new issue