Skip to content

Commit 2fa7bcc

Browse files
authored
refactor(fetch-engine): cleanup promise of fs (#7132)
1 parent f0c9a3c commit 2fa7bcc

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/packages/fetch-engine/src/copy.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/packages/fetch-engine/src/download.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import tempDir from 'temp-dir'
1616
import { promisify } from 'util'
1717
import plusxSync from './chmod'
1818
import { cleanupCache } from './cleanupCache'
19-
import { copy } from './copy'
2019
import { downloadZip } from './downloadZip'
2120
import { flatMap } from './flatMap'
2221
import { getHash } from './getHash'
@@ -28,6 +27,7 @@ const debug = Debug('prisma:download')
2827
const writeFile = promisify(fs.writeFile)
2928
const exists = promisify(fs.exists)
3029
const readFile = promisify(fs.readFile)
30+
const copyFile = promisify(fs.copyFile)
3131

3232
const channel = 'master'
3333
export enum EngineTypes {
@@ -290,14 +290,14 @@ async function binaryNeedsToBeDownloaded(
290290
if (sha256File === sha256Cache) {
291291
if (!targetExists) {
292292
debug(`copying ${cachedFile} to ${job.targetFilePath}`)
293-
await copy(cachedFile, job.targetFilePath)
293+
await copyFile(cachedFile, job.targetFilePath)
294294
}
295295
const targetSha256 = await getHash(job.targetFilePath)
296296
if (sha256File !== targetSha256) {
297297
debug(
298298
`overwriting ${job.targetFilePath} with ${cachedFile} as hashes do not match`,
299299
)
300-
await copy(cachedFile, job.targetFilePath)
300+
await copyFile(cachedFile, job.targetFilePath)
301301
}
302302
return false
303303
} else {
@@ -492,7 +492,7 @@ async function saveFileToCache(
492492
)
493493

494494
try {
495-
await copy(job.targetFilePath, cachedTargetPath)
495+
await copyFile(job.targetFilePath, cachedTargetPath)
496496
await writeFile(cachedSha256Path, sha256)
497497
await writeFile(cachedSha256ZippedPath, zippedSha256)
498498
} catch (e) {

0 commit comments

Comments
 (0)