mirror of
https://github.com/actions/setup-go.git
synced 2026-11-29 19:00:32 +08:00
refactor: simplify split-cache handling
Restore cache entries sequentially, keep saves parallel with per-entry error handling, and simplify the cache test setup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+1
-10
@@ -8,7 +8,6 @@ import {State, Outputs} from './constants.js';
|
||||
import {PackageManagerInfo} from './package-managers.js';
|
||||
import {
|
||||
CacheEntry,
|
||||
canRestoreCachesInParallel,
|
||||
getCacheDirectoryPath,
|
||||
getPackageManagerInfo
|
||||
} from './cache-utils.js';
|
||||
@@ -49,7 +48,7 @@ export const restoreCache = async (
|
||||
primaryKey: primaryKeys[directory.kind]
|
||||
}));
|
||||
|
||||
const restoreEntry = async (entry: CacheEntry) => {
|
||||
for (const entry of entries) {
|
||||
core.debug(`${entry.kind} primary key is ${entry.primaryKey}`);
|
||||
try {
|
||||
entry.matchedKey = await cache.restoreCache(
|
||||
@@ -65,14 +64,6 @@ export const restoreCache = async (
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
core.warning(`Restore ${entry.kind} cache failed: ${message}`);
|
||||
}
|
||||
};
|
||||
|
||||
if (canRestoreCachesInParallel(entries)) {
|
||||
await Promise.all(entries.map(restoreEntry));
|
||||
} else {
|
||||
for (const entry of entries) {
|
||||
await restoreEntry(entry);
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve the resolved paths so the post step uses the same cache versions,
|
||||
|
||||
Reference in New Issue
Block a user