mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-21 16:23:56 +08:00
Allow refreshing cache also with granular save.
This commit is contained in:
parent
df9df7396d
commit
ed8571e5e3
6 changed files with 153 additions and 10 deletions
12
dist/save-only/index.js
vendored
12
dist/save-only/index.js
vendored
|
@ -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
12
dist/save/index.js
vendored
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue