perf: use a suffix for exec files in CAFS, not a dir

Instead of creating a separate subdir for executables in the content-addressable storage, use the directory where all the files are stored but suffix the executable files with `-exec`. Also suffix the package index files with `-index.json`.

ref #2521
PR #2530
This commit is contained in:
Zoltan Kochan
2020-05-05 18:51:29 +03:00
committed by GitHub
parent 5bc033c434
commit 7852deea3f
3 changed files with 9 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/cafs": major
---
Instead of creating a separate subdir for executables in the content-addressable storage, use the directory where all the files are stored but suffix the executable files with `-exec`. Also suffix the package index files with `-index.json`.

View File

@@ -35,10 +35,10 @@ export function contentPathFromHex (fileType: FileType, hex: string) {
const p = path.join(hex.slice(0, 2), hex.slice(2))
switch (fileType) {
case 'exec':
return `x${path.sep}${p}`
return `${p}-exec`
case 'nonexec':
return p
case 'index':
return `${p}.json`
return `${p}-index.json`
}
}

View File

@@ -25,8 +25,8 @@ test('pnpm store add express@4.16.3', async function (t) {
storeDir,
}, ['add', 'express@4.16.3'])
const pathToCheck = path.join(storeDir, STORE_VERSION, 'files/6a/f8a502350db3246ecc4becf6b5a34d22f7ed53.json')
t.ok(await exists(pathToCheck), `express@4.16.3 is in store (at ${pathToCheck})`)
const { cafsHas } = assertStore(t, path.join(storeDir, STORE_VERSION))
await cafsHas('sha1-avilAjUNsyRuzEvs9rWjTSL37VM=')
const storeIndex = await loadJsonFile(path.join(storeDir, STORE_VERSION, 'store.json'))
t.deepEqual(