Skip to content

Commit

Permalink
fix: make shorter temp file names in the store
Browse files Browse the repository at this point in the history
close #6842
  • Loading branch information
zkochan committed Jul 20, 2023
1 parent 9d4c168 commit 277a869
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/green-donuts-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/store.cafs": patch
"pnpm": patch
---

The length of the temporary file names in the content-addressable store reduced in order to prevent `ENAMETOOLONG` errors from happening [#6842](https://github.com/pnpm/pnpm/issues/6842).
8 changes: 7 additions & 1 deletion store/cafs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async function writeBufferToCafs (
//
// If we don't allow --no-verify-store-integrity then we probably can write
// to the final file directly.
const temp = pathTemp(fileDest)
const temp = pathTemp(removeSuffix(fileDest))
await writeFile(temp, buffer, mode)
// Unfortunately, "birth time" (time of file creation) is available not on all filesystems.
// We log the creation time ourselves and save it in the package index file.
Expand All @@ -127,6 +127,12 @@ async function writeBufferToCafs (
return p
}

function removeSuffix (filePath: string): string {
const dashPosition = filePath.indexOf('-')
if (dashPosition === -1) return filePath
return filePath.substring(0, dashPosition)
}

async function existsSame (filename: string, integrity: ssri.IntegrityLike) {
let existingFile: Stats | undefined
try {
Expand Down

0 comments on commit 277a869

Please sign in to comment.