mirror of
https://gitea.com/actions/stale.git
synced 2024-11-30 05:13:33 +08:00
Merge pull request #1080 from akv-platform/fix-delete-cache
Fix delete cache
This commit is contained in:
commit
796531a7b3
@ -29,8 +29,8 @@ You can find more information about the required permissions under the correspon
|
||||
## Statefulness
|
||||
|
||||
If the action ends because of [operations-per-run](#operations-per-run) then the next run will start from the first
|
||||
unprocessed issue skipping the issues proceeded during the previous run(s). The state is reset when all the issues are
|
||||
proceeded. This should be considered for scheduling workflow runs.
|
||||
unprocessed issue skipping the issues processed during the previous run(s). The state is reset when all the issues are
|
||||
processed. This should be considered for scheduling workflow runs.
|
||||
|
||||
The saved state lifetime is the same as the
|
||||
[actions cache](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy)
|
||||
|
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -1636,7 +1636,7 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status) {
|
||||
core.debug(`Cache ${cacheKey} does not exist`);
|
||||
core.warning(`Error delete ${cacheKey}: [${error.status}] ${error.message || 'Unknown reason'}`);
|
||||
}
|
||||
else {
|
||||
throw error;
|
||||
@ -1650,7 +1650,10 @@ class StateCacheStorage {
|
||||
const filePath = path_1.default.join(tmpDir, STATE_FILE);
|
||||
fs_1.default.writeFileSync(filePath, serializedState);
|
||||
try {
|
||||
const cacheExists = yield checkIfCacheExists(CACHE_KEY);
|
||||
if (cacheExists) {
|
||||
yield resetCacheWithOctokit(CACHE_KEY);
|
||||
}
|
||||
const fileSize = fs_1.default.statSync(filePath).size;
|
||||
if (fileSize === 0) {
|
||||
core.info(`the state will be removed`);
|
||||
|
@ -54,7 +54,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise<void> => {
|
||||
);
|
||||
} catch (error) {
|
||||
if (error.status) {
|
||||
core.debug(`Cache ${cacheKey} does not exist`);
|
||||
core.warning(
|
||||
`Error delete ${cacheKey}: [${error.status}] ${
|
||||
error.message || 'Unknown reason'
|
||||
}`
|
||||
);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
@ -67,7 +71,10 @@ export class StateCacheStorage implements IStateStorage {
|
||||
fs.writeFileSync(filePath, serializedState);
|
||||
|
||||
try {
|
||||
const cacheExists = await checkIfCacheExists(CACHE_KEY);
|
||||
if (cacheExists) {
|
||||
await resetCacheWithOctokit(CACHE_KEY);
|
||||
}
|
||||
const fileSize = fs.statSync(filePath).size;
|
||||
|
||||
if (fileSize === 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user