mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
add restore cache error handling
This commit is contained in:
parent
7e4abae443
commit
5d7223261b
3 changed files with 46 additions and 10 deletions
16
dist/cache-save/index.js
vendored
16
dist/cache-save/index.js
vendored
|
@ -57529,8 +57529,20 @@ class CacheDistributor {
|
||||||
const cachePath = yield this.getCacheGlobalDirectories();
|
const cachePath = yield this.getCacheGlobalDirectories();
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
try {
|
||||||
this.handleMatchResult(matchedKey, primaryKey);
|
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(typedError.message);
|
||||||
|
core.setOutput('cache-hit', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleMatchResult(matchedKey, primaryKey) {
|
handleMatchResult(matchedKey, primaryKey) {
|
||||||
|
|
16
dist/setup/index.js
vendored
16
dist/setup/index.js
vendored
|
@ -63600,8 +63600,20 @@ class CacheDistributor {
|
||||||
const cachePath = yield this.getCacheGlobalDirectories();
|
const cachePath = yield this.getCacheGlobalDirectories();
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
try {
|
||||||
this.handleMatchResult(matchedKey, primaryKey);
|
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
|
||||||
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const typedError = error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(typedError.message);
|
||||||
|
core.setOutput('cache-hit', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleMatchResult(matchedKey, primaryKey) {
|
handleMatchResult(matchedKey, primaryKey) {
|
||||||
|
|
|
@ -35,13 +35,25 @@ abstract class CacheDistributor {
|
||||||
core.saveState(State.CACHE_PATHS, cachePath);
|
core.saveState(State.CACHE_PATHS, cachePath);
|
||||||
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
|
||||||
|
|
||||||
const matchedKey = await cache.restoreCache(
|
try {
|
||||||
cachePath,
|
const matchedKey = await cache.restoreCache(
|
||||||
primaryKey,
|
cachePath,
|
||||||
restoreKey
|
primaryKey,
|
||||||
);
|
restoreKey
|
||||||
|
);
|
||||||
|
|
||||||
|
this.handleMatchResult(matchedKey, primaryKey);
|
||||||
|
} catch(error) {
|
||||||
|
const typedError = error as Error;
|
||||||
|
if (typedError.name === cache.ValidationError.name) {
|
||||||
|
throw error;
|
||||||
|
} else {
|
||||||
|
core.warning(typedError.message);
|
||||||
|
core.setOutput('cache-hit', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.handleMatchResult(matchedKey, primaryKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
|
public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue