@preventive/archive 1.0.0-beta.2 → 1.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/entry.js +1 -1
- package/src/names.js +2 -2
- package/src/tar/pack.js +1 -1
- package/src/tar/unpack.js +2 -2
- package/tar.d.ts +4 -3
package/package.json
CHANGED
package/src/entry.js
CHANGED
|
@@ -29,6 +29,6 @@ export function checkEntry(entry, types) {
|
|
|
29
29
|
if (data.length !== 0 && !isFile(type)) throw new ArchiveError(`a ${type} cannot carry data (${quote(name)})`)
|
|
30
30
|
const linkname = entry.linkname ?? ''
|
|
31
31
|
checkString(linkname, `link target of ${quote(name)}`)
|
|
32
|
-
if (linkname !== '' && type !== '
|
|
32
|
+
if (linkname !== '' && type !== 'hardlink' && type !== 'symlink') throw new ArchiveError(`a ${type} cannot have a link target (${quote(name)})`)
|
|
33
33
|
return { name, type, data, linkname }
|
|
34
34
|
}
|
package/src/names.js
CHANGED
|
@@ -91,7 +91,7 @@ export function cleanNames(path, type, target) {
|
|
|
91
91
|
const name = cleanPath(path, 'entry name', type === 'directory')
|
|
92
92
|
let linkname = target
|
|
93
93
|
if (type === 'symlink') checkSymlinkTarget(name, target)
|
|
94
|
-
else if (type === '
|
|
94
|
+
else if (type === 'hardlink') linkname = cleanPath(target, `hard link target of ${quote(name)}`)
|
|
95
95
|
return { name, linkname }
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -147,7 +147,7 @@ export class Names {
|
|
|
147
147
|
// The target of the symlink this entry is, if it is one: a symlink's
|
|
148
148
|
// own, or, for a hard link, that of the entry it links to.
|
|
149
149
|
let symlink = type === 'symlink' ? entry.linkname : undefined
|
|
150
|
-
if (type === '
|
|
150
|
+
if (type === 'hardlink') {
|
|
151
151
|
const target = this.#find(entry.linkname)
|
|
152
152
|
if (target?.kind !== 'entry') throw new ArchiveError(`hard link ${quote(name)} targets ${quote(entry.linkname)}, which is not an earlier non-directory entry`)
|
|
153
153
|
// A hard link to a symlink is a second name for that symlink, and a
|
package/src/tar/pack.js
CHANGED
package/src/tar/unpack.js
CHANGED
|
@@ -14,7 +14,7 @@ import { decodeUtf8, hasUnsafe, quote } from '../text.js'
|
|
|
14
14
|
|
|
15
15
|
// NUL is the pre-POSIX regular file.
|
|
16
16
|
const TYPES = new Map([
|
|
17
|
-
[0x30, 'file'], [0, 'file'], [0x31, '
|
|
17
|
+
[0x30, 'file'], [0, 'file'], [0x31, 'hardlink'], [0x32, 'symlink'], [0x33, 'character-device'],
|
|
18
18
|
[0x34, 'block-device'], [0x35, 'directory'], [0x36, 'fifo'], [0x37, 'contiguous-file'],
|
|
19
19
|
])
|
|
20
20
|
const EXTENDED = new Map([[0x78, 'pax'], [0x67, 'global'], [0x4c, 'longname'], [0x4b, 'longlink']])
|
|
@@ -209,7 +209,7 @@ class Unpacker {
|
|
|
209
209
|
}
|
|
210
210
|
const size = number('size')
|
|
211
211
|
if (size !== 0 && !isFile(type)) throw new ArchiveError(`a ${type} entry has a size`, at)
|
|
212
|
-
if (linkname !== '' && type !== '
|
|
212
|
+
if (linkname !== '' && type !== 'hardlink' && type !== 'symlink') throw new ArchiveError(`a ${type} entry has a link target`, at)
|
|
213
213
|
const owner = (key) => {
|
|
214
214
|
const value = record(key) ?? decodeUtf8(header[key], key, at)
|
|
215
215
|
if (hasUnsafe(value, false)) throw new ArchiveError(`${key} ${quote(value)} holds a control or formatting character`, at)
|
package/tar.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// The typed contract for archive/tar.js, hand-written: keep it name for name
|
|
2
2
|
// with tar.js, and change it in the same commit as the signature.
|
|
3
3
|
|
|
4
|
-
// tar's entry types under tar-stream's names
|
|
5
|
-
//
|
|
4
|
+
// tar's entry types under tar-stream's names, but for a 'hardlink', which
|
|
5
|
+
// tar-stream calls a 'link': a hard link to an earlier entry. A
|
|
6
|
+
// 'contiguous-file' is a file for every purpose here.
|
|
6
7
|
export type EntryType =
|
|
7
8
|
| 'file'
|
|
8
9
|
| 'directory'
|
|
9
10
|
| 'symlink'
|
|
10
|
-
| '
|
|
11
|
+
| 'hardlink'
|
|
11
12
|
| 'fifo'
|
|
12
13
|
| 'character-device'
|
|
13
14
|
| 'block-device'
|