mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-07 14:38:32 -05:00
fix: unpacking tarballs that contain hard links (#7062)
This commit is contained in:
6
.changeset/modern-wombats-tease.md
Normal file
6
.changeset/modern-wombats-tease.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/store.cafs": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Tarballs that have hard links are now unpacked successfully. This fixes a regression introduced in v8.7.0, which was shipped with our new in-house tarball parser [#7062](https://github.com/pnpm/pnpm/pull/7062).
|
||||
@@ -12,6 +12,7 @@ export interface IFile {
|
||||
}
|
||||
|
||||
const ZERO: number = '0'.charCodeAt(0)
|
||||
const FILE_TYPE_HARD_LINK: number = '1'.charCodeAt(0)
|
||||
const FILE_TYPE_SYMLINK: number = '2'.charCodeAt(0)
|
||||
const FILE_TYPE_DIRECTORY: number = '5'.charCodeAt(0)
|
||||
const SPACE: number = ' '.charCodeAt(0)
|
||||
@@ -135,6 +136,7 @@ export function parseTarball (buffer: Buffer): IParseResult {
|
||||
switch (fileType) {
|
||||
case 0:
|
||||
case ZERO:
|
||||
case FILE_TYPE_HARD_LINK:
|
||||
// The file mode is an octal number encoded as UTF-8. It is terminated by a NUL or space. Maximum length 8 characters.
|
||||
mode = parseOctal(blockStart + MODE_OFFSET, 8)
|
||||
|
||||
|
||||
BIN
store/cafs/test/fixtures/vue.examples.todomvc.todo-store-0.0.1.tgz
vendored
Normal file
BIN
store/cafs/test/fixtures/vue.examples.todomvc.todo-store-0.0.1.tgz
vendored
Normal file
Binary file not shown.
@@ -113,3 +113,12 @@ test('unpack an older version of tar that prefixes with spaces', () => {
|
||||
'package.json',
|
||||
])
|
||||
})
|
||||
|
||||
test('unpack a tarball that contains hard links', () => {
|
||||
const dest = tempy.directory()
|
||||
const cafs = createCafs(dest)
|
||||
const { filesIndex } = cafs.addFilesFromTarball(
|
||||
fs.readFileSync(path.join(__dirname, 'fixtures/vue.examples.todomvc.todo-store-0.0.1.tgz'))
|
||||
)
|
||||
expect(Object.keys(filesIndex).length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user