MCPcopy
hub / github.com/prisma/prisma / getCachedBinaryPath

Function getCachedBinaryPath

packages/fetch-engine/src/download.ts:353–380  ·  view source on GitHub ↗
({
  version,
  binaryTarget,
  binaryName,
}: GetCachedBinaryOptions)

Source from the content-addressed store, hash-verified

351}
352
353async function getCachedBinaryPath({
354 version,
355 binaryTarget,
356 binaryName,
357}: GetCachedBinaryOptions): Promise<string | null> {
358 const cacheDir = await getCacheDir(channel, version, binaryTarget)
359 if (!cacheDir) {
360 return null
361 }
362
363 const cachedTargetPath = path.join(cacheDir, binaryName)
364
365 if (!fs.existsSync(cachedTargetPath)) {
366 return null
367 }
368
369 // All versions not called 'latest' are unique
370 // only latest needs more checks
371 if (version !== 'latest') {
372 return cachedTargetPath
373 }
374
375 if (await exists(cachedTargetPath)) {
376 return cachedTargetPath
377 }
378
379 return null
380}
381
382type DownloadBinaryOptions = BinaryDownloadJob & {
383 version: string

Callers 1

Calls 2

getCacheDirFunction · 0.90
existsFunction · 0.50

Tested by

no test coverage detected