wrap with try, debugging errors

Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
Anton Troshin 2024-11-19 16:20:55 -06:00
parent 896e2cbf0f
commit c8eefa5dde
No known key found for this signature in database
GPG key ID: 9F8A96ACA9EB6363

View file

@ -235,22 +235,28 @@ 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}`);
if (!fs.existsSync(cachePath.actualPath)) { try {
core.info(`Creating directory ${cachePath.actualPath}`); if (!fs.existsSync(cachePath.actualPath)) {
fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true}); core.info(`Creating directory ${cachePath.actualPath}`);
} else { fs.mkdirSync(path.dirname(cachePath.actualPath), {recursive: true});
core.info(`Directory ${cachePath.actualPath} already exists`); } else {
} core.info(`Directory ${cachePath.actualPath} already exists`);
// make sure the link is pointing to the actual cache directory }
const symlinkTarget = fs.readlinkSync(cachePath.defaultPath);
core.info(`Symlink target: ${symlinkTarget}`); // check if the default path is a symlink
if (symlinkTarget !== "") { const isSymlink = fs.lstatSync(cachePath.defaultPath).isSymbolicLink();
core.info(`Found link ${cachePath.defaultPath} => ${symlinkTarget}`); if (isSymlink) {
} else { core.info(`Default path is symlink ${cachePath.defaultPath} => ${fs.readlinkSync(cachePath.defaultPath)}`);
fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction'); } else {
core.info( core.info(`Default path is not a symlink ${cachePath.defaultPath}`);
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}` fs.symlinkSync(cachePath.actualPath, cachePath.defaultPath, 'junction');
); core.info(
`Created link ${cachePath.defaultPath} => ${cachePath.actualPath}`
);
}
} catch (err) {
core.info(`Failed to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
core.info('Error: ' + err);
} }
} }