MCPcopy Index your code
hub / github.com/actions/setup-python / restoreCache

Function restoreCache

src/cache-distributions/cache-distributor.ts:53–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51 }
52
53 public async restoreCache() {
54 const {primaryKey, restoreKey} = await this.computeKeys();
55 if (primaryKey.endsWith('-')) {
56 const file =
57 this.packageManager === 'pip'
58 ? `${this.cacheDependencyPath
59 .split('\n')
60 .join(',')} or ${CACHE_DEPENDENCY_BACKUP_PATH}`
61 : this.cacheDependencyPath.split('\n').join(',');
62 throw new Error(
63 `No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`
64 );
65 }
66
67 const cachePath = await this.getCacheGlobalDirectories();
68
69 core.saveState(State.CACHE_PATHS, cachePath);
70
71 let matchedKey: string | undefined;
72 try {
73 matchedKey = await cache.restoreCache(cachePath, primaryKey, restoreKey);
74 } catch (err) {
75 const message = (err as Error).message;
76 core.info(`[warning]${message}`);
77 core.setOutput('cache-hit', false);
78 return;
79 }
80
81 core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
82
83 await this.handleLoadedCache();
84
85 this.handleMatchResult(matchedKey, primaryKey);
86 }
87
88 public handleMatchResult(matchedKey: string | undefined, primaryKey: string) {
89 if (matchedKey) {

Callers

nothing calls this directly

Calls 3

handleLoadedCacheMethod · 0.80
computeKeysMethod · 0.45

Tested by

no test coverage detected