mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-07 14:38:32 -05:00
fix: don't unpack file duplicates
This commit is contained in:
5
.changeset/hot-wombats-sort.md
Normal file
5
.changeset/hot-wombats-sort.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/cafs": patch
|
||||
---
|
||||
|
||||
Don't unpack file duplicates to the content-addressable store.
|
||||
@@ -14,9 +14,9 @@ export default async function (
|
||||
const extract = tar.extract()
|
||||
const filesIndex = {}
|
||||
await new Promise((resolve, reject) => {
|
||||
extract.on('entry', async (header, fileStream, next) => {
|
||||
const filename = header.name.substr(header.name.indexOf('/') + 1)
|
||||
if (header.type !== 'file' || ignore(filename)) {
|
||||
extract.on('entry', (header, fileStream, next) => {
|
||||
const filename = header.name.substr(header.name.indexOf('/') + 1).replace(/\/\//g, '/')
|
||||
if (header.type !== 'file' || ignore(filename) || filesIndex[filename]) {
|
||||
fileStream.resume()
|
||||
next()
|
||||
return
|
||||
|
||||
BIN
packages/cafs/test/fixtures/colorize-semver-diff.tgz
vendored
Normal file
BIN
packages/cafs/test/fixtures/colorize-semver-diff.tgz
vendored
Normal file
Binary file not shown.
@@ -52,3 +52,19 @@ describe('checkFilesIntegrity()', () => {
|
||||
})).toBeFalsy()
|
||||
})
|
||||
})
|
||||
|
||||
test('file names are normalized when unpacking a tarball', async () => {
|
||||
const dest = tempy.directory()
|
||||
console.log(dest)
|
||||
const cafs = createCafs(dest)
|
||||
const filesIndex = await cafs.addFilesFromTarball(
|
||||
fs.createReadStream(path.join(__dirname, 'fixtures/colorize-semver-diff.tgz'))
|
||||
)
|
||||
expect(Object.keys(filesIndex).sort()).toStrictEqual([
|
||||
'LICENSE',
|
||||
'README.md',
|
||||
'lib/index.d.ts',
|
||||
'lib/index.js',
|
||||
'package.json',
|
||||
])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user