Allow refreshing cache also with granular save.

This commit is contained in:
Gregorio Litenstein 2023-04-07 21:53:06 -04:00
parent df9df7396d
commit ed8571e5e3
No known key found for this signature in database
GPG key ID: 4EB52A1A9CE2C63F
6 changed files with 153 additions and 10 deletions

View file

@ -78737,8 +78737,16 @@ function saveImpl(stateProvider) {
return;
}
const refreshCache = utils.getInputAsBool(constants_1.Inputs.RefreshCache, { required: false });
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save (NO-OP in case of SaveOnly action)
const restoredKey = stateProvider.getCacheState();
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save.
let restoredKey = stateProvider.getCacheState();
if (refreshCache && !restoredKey) {
// If getCacheState didn't give us a key, we're likely using granular actions. Do a lookup to see if we need to refresh or just do a regular save.
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
restoredKey = yield cache.restoreCache(cachePaths, primaryKey, [], { lookupOnly: true }, enableCrossOsArchive);
}
if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env || null;
if (GITHUB_TOKEN && GITHUB_REPOSITORY && refreshCache === true) {

12
dist/save/index.js vendored
View file

@ -78737,8 +78737,16 @@ function saveImpl(stateProvider) {
return;
}
const refreshCache = utils.getInputAsBool(constants_1.Inputs.RefreshCache, { required: false });
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save (NO-OP in case of SaveOnly action)
const restoredKey = stateProvider.getCacheState();
// If matched restore key is same as primary key, either try to refresh the cache, or just notify and do not save.
let restoredKey = stateProvider.getCacheState();
if (refreshCache && !restoredKey) {
// If getCacheState didn't give us a key, we're likely using granular actions. Do a lookup to see if we need to refresh or just do a regular save.
const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, {
required: true
});
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
restoredKey = yield cache.restoreCache(cachePaths, primaryKey, [], { lookupOnly: true }, enableCrossOsArchive);
}
if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env || null;
if (GITHUB_TOKEN && GITHUB_REPOSITORY && refreshCache === true) {