Pack large UID and GIDs as 777777
This commit is contained in:
parent
092cb99608
commit
58ff1564b7
4 changed files with 27 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
var ZEROS = '0000000000000000000'
|
||||
var SEVENS = '7777777777777777777'
|
||||
var ZERO_OFFSET = '0'.charCodeAt(0)
|
||||
var USTAR = 'ustar\x0000'
|
||||
var MASK = parseInt('7777', 8)
|
||||
|
@ -92,7 +93,8 @@ var cksum = function (block) {
|
|||
|
||||
var encodeOct = function (val, n) {
|
||||
val = val.toString(8)
|
||||
return ZEROS.slice(0, n - val.length) + val + ' '
|
||||
if (val.length > n) return SEVENS.slice(0, n) + ' '
|
||||
else return ZEROS.slice(0, n - val.length) + val + ' '
|
||||
}
|
||||
|
||||
/* Copied from the node-tar repo and modified to meet
|
||||
|
|
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
|
@ -12,3 +12,4 @@ exports.INVALID_TGZ = path.join(__dirname, 'invalid.tgz')
|
|||
exports.SPACE_TAR_GZ = path.join(__dirname, 'space.tar')
|
||||
exports.GNU_LONG_PATH = path.join(__dirname, 'gnu-long-path.tar')
|
||||
exports.BASE_256_UID_GID = path.join(__dirname, 'base-256-uid-gid.tar')
|
||||
exports.LARGE_UID_GID = path.join(__dirname, 'large-uid-gid.tar')
|
||||
|
|
BIN
test/fixtures/large-uid-gid.tar
vendored
Normal file
BIN
test/fixtures/large-uid-gid.tar
vendored
Normal file
Binary file not shown.
23
test/pack.js
23
test/pack.js
|
@ -145,6 +145,29 @@ test('long-name', function (t) {
|
|||
}))
|
||||
})
|
||||
|
||||
test('large-uid-gid', function (t) {
|
||||
t.plan(2)
|
||||
var pack = tar.pack()
|
||||
|
||||
pack.entry({
|
||||
name: 'test.txt',
|
||||
mtime: new Date(1387580181000),
|
||||
mode: parseInt('644', 8),
|
||||
uname: 'maf',
|
||||
gname: 'staff',
|
||||
uid: 1000000001,
|
||||
gid: 1000000002
|
||||
}, 'hello world\n')
|
||||
|
||||
pack.finalize()
|
||||
|
||||
pack.pipe(concat(function (data) {
|
||||
t.same(data.length & 511, 0)
|
||||
t.deepEqual(data, fs.readFileSync(fixtures.LARGE_UID_GID))
|
||||
fs.writeFileSync('/tmp/foo', data)
|
||||
}))
|
||||
})
|
||||
|
||||
test('unicode', function (t) {
|
||||
t.plan(2)
|
||||
var pack = tar.pack()
|
||||
|
|
Loading…
Reference in a new issue