MCPcopy Create free account
hub / github.com/vercel/vercel / prepareCache

Function prepareCache

packages/container/src/prepare-cache.ts:26–53  ·  view source on GitHub ↗
(
  _options: PrepareCacheOptions
)

Source from the content-addressed store, hash-verified

24 * `VERCEL_VCR_DISABLE_LAYER_CACHE=1`.
25 */
26export async function prepareCache(
27 _options: PrepareCacheOptions
28): Promise<Files> {
29 if (process.env.VERCEL_VCR_DISABLE_LAYER_CACHE) {
30 debug('layer cache disabled (VERCEL_VCR_DISABLE_LAYER_CACHE)');
31 return {};
32 }
33
34 // The buildah store only exists in the build container.
35 if (!isBuildContainer()) {
36 debug('skipping container layer cache (not in build container)');
37 return {};
38 }
39
40 if (!existsSync(BUILDAH_GRAPH_ROOT)) {
41 debug(`no buildah store to cache at ${BUILDAH_GRAPH_ROOT}`);
42 return {};
43 }
44
45 const start = Date.now();
46 const files = await glob(`${GRAPH_ROOT_REL}/**`, CACHE_ROOT);
47 const count = Object.keys(files).length;
48 info(
49 `cached container layer store: ${count} files from ${BUILDAH_GRAPH_ROOT} ` +
50 `in ${Date.now() - start}ms`
51 );
52 return files;
53}

Callers 1

unit.test.tsFile · 0.90

Calls 5

debugFunction · 0.90
isBuildContainerFunction · 0.90
globFunction · 0.90
infoFunction · 0.90
keysMethod · 0.45

Tested by

no test coverage detected