3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-12-25 22:37:00 +00:00

Merge remote-tracking branch 'upstream/main' into fix/v4-update

This commit is contained in:
Cyril Rohr 2024-05-21 17:58:44 +00:00
commit 4c85713eab
9 changed files with 117 additions and 106 deletions

View file

@ -13,7 +13,8 @@ import * as custom from "./custom/cache";
const canSaveToS3 = process.env["RUNS_ON_S3_BUCKET_CACHE"] !== undefined;
export async function restoreImpl(
stateProvider: IStateProvider
stateProvider: IStateProvider,
earlyExit?: boolean | undefined
): Promise<string | undefined> {
try {
if (!utils.isCacheFeatureAvailable()) {
@ -100,6 +101,9 @@ export async function restoreImpl(
return cacheKey;
} catch (error: unknown) {
core.setFailed((error as Error).message);
if (earlyExit) {
process.exit(1);
}
}
}
@ -107,14 +111,7 @@ async function run(
stateProvider: IStateProvider,
earlyExit: boolean | undefined
): Promise<void> {
try {
await restoreImpl(stateProvider);
} catch (err) {
console.error(err);
if (earlyExit) {
process.exit(1);
}
}
await restoreImpl(stateProvider, earlyExit);
// node will stay alive if any promises are not resolved,
// which is a possibility if HTTP requests are dangling