mirror of
https://github.com/actions/setup-go.git
synced 2025-06-18 23:02:59 -06:00
remove empty cache folders to be able to create symlinks
Signed-off-by: Anton Troshin <anton@diagrid.io>
This commit is contained in:
parent
e91efc513b
commit
5b1dffca1b
2 changed files with 28 additions and 18 deletions
|
@ -237,9 +237,18 @@ async function cacheWindowsDir(
|
|||
core.info(`Trying to link ${cachePath.defaultPath} to ${cachePath.actualPath}`);
|
||||
try {
|
||||
// the symlink already exists, skip
|
||||
if (fs.existsSync(cachePath.defaultPath) && fs.lstatSync(cachePath.defaultPath).isSymbolicLink()) {
|
||||
const stats = fs.lstatSync(cachePath.defaultPath);
|
||||
if (fs.existsSync(cachePath.defaultPath) && stats.isSymbolicLink()) {
|
||||
core.info(`Directory ${cachePath.defaultPath} already linked. Skipping`);
|
||||
continue
|
||||
}
|
||||
// the directory is empty, delete it to be able to create a symlink
|
||||
if (stats.size == 0) {
|
||||
fs.rmSync(cachePath.defaultPath, {recursive: true, force: true});
|
||||
} else {
|
||||
core.info(`Directory ${cachePath.defaultPath} is not empty. Skipping`);
|
||||
continue;
|
||||
}
|
||||
// create a parent directory where the link will be created
|
||||
fs.mkdirSync(path.dirname(cachePath.defaultPath), {recursive: true});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue