From 5c8d5f1e26e508c755109988232f13062358c8de Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Tue, 30 Jan 2024 23:59:06 -0500 Subject: [PATCH] restoreCache only cleanup in finally if archivePath is set --- packages/cache/src/cache.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/cache/src/cache.ts b/packages/cache/src/cache.ts index f7fadb6f..27a7bc24 100644 --- a/packages/cache/src/cache.ts +++ b/packages/cache/src/cache.ts @@ -142,11 +142,13 @@ export async function restoreCache( core.warning(`Failed to restore: ${(error as Error).message}`) } } finally { - // Try to delete the archive to save space - try { - await utils.unlinkFile(archivePath) - } catch (error) { - core.debug(`Failed to delete archive: ${error}`) + if (archivePath) { + // Try to delete the archive to save space + try { + await utils.unlinkFile(archivePath) + } catch (error) { + core.debug(`Failed to delete archive: ${error}`) + } } }