mirror of
https://github.com/actions/setup-python.git
synced 2025-07-05 09:03:46 +00:00
add error handling for cache
This commit is contained in:
parent
7b9ef6fc5a
commit
35437f7fe8
5 changed files with 689 additions and 1051 deletions
|
@ -39,13 +39,18 @@ abstract class CacheDistributor {
|
|||
const cachePath = await this.getCacheGlobalDirectories();
|
||||
|
||||
core.saveState(State.CACHE_PATHS, cachePath);
|
||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
|
||||
const matchedKey = await cache.restoreCache(
|
||||
cachePath,
|
||||
primaryKey,
|
||||
restoreKey
|
||||
);
|
||||
let matchedKey: string | undefined;
|
||||
try {
|
||||
matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.info(`[warning]${message}`);
|
||||
core.setOutput('cache-hit', false);
|
||||
return;
|
||||
}
|
||||
|
||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||
|
||||
await this.handleLoadedCache();
|
||||
|
||||
|
|
|
@ -43,7 +43,16 @@ async function saveCache(packageManager: string) {
|
|||
return;
|
||||
}
|
||||
|
||||
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||
let cacheId = 0;
|
||||
|
||||
try {
|
||||
cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||
} catch (err) {
|
||||
const message = (err as Error).message;
|
||||
core.info(`[warning]${message}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cacheId == -1) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue