4
0
Fork 0
mirror of https://github.com/actions/cache.git synced 2025-11-07 10:36:55 +00:00

Compare commits

...

2 commits

Author SHA1 Message Date
itchyny
d947bc533d
Merge 5cdbd5c7ec into 638ed79f9d 2025-08-15 15:20:14 +09:00
itchyny
5cdbd5c7ec Avoid re-evaluation of the key input in restore implementation 2024-10-06 08:41:39 +09:00
3 changed files with 3 additions and 7 deletions

View file

@ -66139,7 +66139,7 @@ function restoreImpl(stateProvider, earlyExit) {
} }
// Store the matched cache key in states // Store the matched cache key in states
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); 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()); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) { if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`); core.info(`Cache found and can be restored from key: ${cacheKey}`);

View file

@ -66139,7 +66139,7 @@ function restoreImpl(stateProvider, earlyExit) {
} }
// Store the matched cache key in states // Store the matched cache key in states
stateProvider.setState(constants_1.State.CacheMatchedKey, cacheKey); 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()); core.setOutput(constants_1.Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) { if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`); core.info(`Cache found and can be restored from key: ${cacheKey}`);

View file

@ -71,11 +71,7 @@ export async function restoreImpl(
// Store the matched cache key in states // Store the matched cache key in states
stateProvider.setState(State.CacheMatchedKey, cacheKey); stateProvider.setState(State.CacheMatchedKey, cacheKey);
const isExactKeyMatch = utils.isExactKeyMatch( const isExactKeyMatch = utils.isExactKeyMatch(primaryKey, cacheKey);
core.getInput(Inputs.Key, { required: true }),
cacheKey
);
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString()); core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
if (lookupOnly) { if (lookupOnly) {
core.info(`Cache found and can be restored from key: ${cacheKey}`); core.info(`Cache found and can be restored from key: ${cacheKey}`);