fix: concurrently hard linking a directory (#10181)

close #10179
This commit is contained in:
Zoltan Kochan
2025-11-12 14:07:18 +01:00
committed by GitHub
parent ba70035691
commit 0fd53e10bd
2 changed files with 8 additions and 2 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/fs.hard-link-dir": patch
"pnpm": patch
---
Don't crash when two processes of pnpm are hardlinking the contents of a directory to the same destination simultaneously [#10179](https://github.com/pnpm/pnpm/issues/10179).

View File

@@ -5,7 +5,7 @@ import fs from 'fs'
import { globalWarn } from '@pnpm/logger'
import gfs from '@pnpm/graceful-fs'
import { sync as renameOverwrite } from 'rename-overwrite'
import { fastPathTemp as pathTemp } from 'path-temp'
import pathTemp from 'path-temp'
export function hardLinkDir (src: string, destDirs: string[]): void {
if (destDirs.length === 0) return
@@ -17,7 +17,7 @@ export function hardLinkDir (src: string, destDirs: string[]): void {
continue
}
filteredDestDirs.push(destDir)
tempDestDirs.push(pathTemp(destDir))
tempDestDirs.push(pathTemp(path.dirname(destDir)))
}
_hardLinkDir(src, tempDestDirs, true)
for (let i = 0; i < filteredDestDirs.length; i++) {