MCPcopy
hub / github.com/prisma/prisma / saveFileToCache

Function saveFileToCache

packages/fetch-engine/src/download.ts:422–450  ·  view source on GitHub ↗
(
  job: BinaryDownloadJob,
  version: string,
  sha256: string | null,
  zippedSha256: string | null,
)

Source from the content-addressed store, hash-verified

420}
421
422async function saveFileToCache(
423 job: BinaryDownloadJob,
424 version: string,
425 sha256: string | null,
426 zippedSha256: string | null,
427): Promise<void> {
428 // always fail silent, as the cache is optional
429 const cacheDir = await getCacheDir(channel, version, job.binaryTarget)
430 if (!cacheDir) {
431 return
432 }
433
434 const cachedTargetPath = path.join(cacheDir, job.binaryName)
435 const cachedSha256Path = path.join(cacheDir, job.binaryName + '.sha256')
436 const cachedSha256ZippedPath = path.join(cacheDir, job.binaryName + '.gz.sha256')
437
438 try {
439 await overwriteFile(job.targetFilePath, cachedTargetPath)
440 if (sha256 != null) {
441 await fs.promises.writeFile(cachedSha256Path, sha256)
442 }
443 if (zippedSha256 != null) {
444 await fs.promises.writeFile(cachedSha256ZippedPath, zippedSha256)
445 }
446 } catch (e) {
447 debug(e)
448 // let this fail silently - the CI system may have reached the file size limit
449 }
450}
451
452export async function maybeCopyToTmp(file: string): Promise<string> {
453 // in this case, we are in a "pkg" context with a virtual fs

Callers 1

downloadBinaryFunction · 0.85

Calls 3

getCacheDirFunction · 0.90
overwriteFileFunction · 0.90
debugFunction · 0.85

Tested by

no test coverage detected