From 461004e4c97225a313a997efabc35fde47d587bb Mon Sep 17 00:00:00 2001
From: Anton Troshin <18515134+antontroshin@users.noreply.github.com>
Date: Thu, 12 Jun 2025 02:24:23 -0500
Subject: [PATCH] fix: add check for D: drive existence in Windows cache
 directory setup

Signed-off-by: Anton Troshin <18515134+antontroshin@users.noreply.github.com>
---
 dist/setup/index.js  | 2 ++
 src/cache-restore.ts | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/dist/setup/index.js b/dist/setup/index.js
index 65f423f..b6cfc3f 100644
--- a/dist/setup/index.js
+++ b/dist/setup/index.js
@@ -93114,6 +93114,8 @@ exports.restoreCache = restoreCache;
 const setWindowsCacheDirectories = () => __awaiter(void 0, void 0, void 0, function* () {
     if (os_1.default.platform() !== 'win32')
         return;
+    if (!fs_1.default.existsSync('D:'))
+        return;
     let goCache = yield (0, cache_utils_1.getCommandOutput)(`go env GOCACHE`);
     core.info(`GOCACHE: ${goCache}`);
     goCache = goCache.replace('C:', 'D:').replace('c:', 'd:');
diff --git a/src/cache-restore.ts b/src/cache-restore.ts
index a170a2f..dccdd19 100644
--- a/src/cache-restore.ts
+++ b/src/cache-restore.ts
@@ -58,6 +58,8 @@ export const restoreCache = async (
 export const setWindowsCacheDirectories = async () => {
   if (os.platform() !== 'win32') return;
 
+  if (!fs.existsSync('D:')) return;
+
   let goCache = await getCommandOutput(`go env GOCACHE`);
   core.info(`GOCACHE: ${goCache}`);
   goCache = goCache.replace('C:', 'D:').replace('c:', 'd:');