From 4e7ce9ad41b64d1caf2550a3074fe547c06c8f4d Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 14 Apr 2024 22:44:33 +0900 Subject: [PATCH] Avoid re-evaluation of the key input in restore implementation --- dist/restore-only/index.js | 2 +- dist/restore/index.js | 2 +- src/restoreImpl.ts | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 9a59ac0..1134ea6 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -59426,7 +59426,7 @@ function restoreImpl(stateProvider, earlyExit) { } // Store the matched cache key in states stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); - const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey); + const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString()); if (lookupOnly) { core.info(`Cache found and can be restored from key: ${cacheKey}`); diff --git a/dist/restore/index.js b/dist/restore/index.js index 03a12b5..2db12a1 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -59426,7 +59426,7 @@ function restoreImpl(stateProvider, earlyExit) { } // Store the matched cache key in states stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); - const isExactKeyMatch = utils.isExactKeyMatch(core.getInput(constants_1.Inputs.Key, { required: true }), cacheKey); + const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString()); if (lookupOnly) { core.info(`Cache found and can be restored from key: ${cacheKey}`); diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 74a366d..5ede771 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -69,11 +69,7 @@ export async function restoreImpl( // Store the matched cache key in states stateProvider.setState(State.CacheMatchedKey, cacheKey); - const isExactKeyMatch = utils.isExactKeyMatch( - core.getInput(Inputs.Key, { required: true }), - cacheKey - ); - + const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey); core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString()); if (lookupOnly) { core.info(`Cache found and can be restored from key: ${cacheKey}`);