2022-12-06 15:04:04 +00:00
|
|
|
const test = require('brittle')
|
|
|
|
const zlib = require('zlib')
|
|
|
|
const fs = require('fs')
|
|
|
|
const { Writable } = require('streamx')
|
|
|
|
const tar = require('../..')
|
|
|
|
const fixtures = require('../fixtures')
|
2018-03-21 19:32:29 +00:00
|
|
|
|
|
|
|
test('huge', function (t) {
|
2023-06-17 17:11:53 +00:00
|
|
|
t.plan(3)
|
2018-03-21 19:32:29 +00:00
|
|
|
|
2022-12-06 15:04:04 +00:00
|
|
|
const extract = tar.extract()
|
|
|
|
let noEntries = false
|
|
|
|
const hugeFileSize = 8804630528 // ~8.2GB
|
|
|
|
let dataLength = 0
|
2018-03-21 19:32:29 +00:00
|
|
|
|
2022-12-06 15:04:04 +00:00
|
|
|
const countStream = new Writable({
|
|
|
|
write (data, cb) {
|
|
|
|
dataLength += data.length
|
|
|
|
cb()
|
|
|
|
}
|
|
|
|
})
|
2018-03-21 19:32:29 +00:00
|
|
|
|
|
|
|
// Make sure we read the correct pax size entry for a file larger than 8GB.
|
|
|
|
extract.on('entry', function (header, stream, callback) {
|
2022-12-06 15:04:04 +00:00
|
|
|
t.alike(header, {
|
2018-03-21 19:32:29 +00:00
|
|
|
devmajor: 0,
|
|
|
|
devminor: 0,
|
|
|
|
gid: 20,
|
|
|
|
gname: 'staff',
|
|
|
|
linkname: null,
|
|
|
|
mode: 420,
|
|
|
|
mtime: new Date(1521214967000),
|
|
|
|
name: 'huge.txt',
|
|
|
|
pax: {
|
|
|
|
'LIBARCHIVE.creationtime': '1521214954',
|
|
|
|
'SCHILY.dev': '16777218',
|
|
|
|
'SCHILY.ino': '91584182',
|
|
|
|
'SCHILY.nlink': '1',
|
|
|
|
atime: '1521214969',
|
|
|
|
ctime: '1521214967',
|
|
|
|
size: hugeFileSize.toString()
|
|
|
|
},
|
|
|
|
size: hugeFileSize,
|
|
|
|
type: 'file',
|
|
|
|
uid: 502,
|
|
|
|
uname: 'apd4n'
|
|
|
|
})
|
|
|
|
|
|
|
|
noEntries = true
|
|
|
|
stream.pipe(countStream)
|
2023-06-17 17:11:53 +00:00
|
|
|
callback()
|
2018-03-21 19:32:29 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
extract.on('finish', function () {
|
|
|
|
t.ok(noEntries)
|
2022-12-06 15:04:04 +00:00
|
|
|
t.is(dataLength, hugeFileSize)
|
2018-03-21 19:32:29 +00:00
|
|
|
})
|
|
|
|
|
2022-12-06 15:04:04 +00:00
|
|
|
const gunzip = zlib.createGunzip()
|
|
|
|
const reader = fs.createReadStream(fixtures.HUGE)
|
2018-03-21 19:32:29 +00:00
|
|
|
reader.pipe(gunzip).pipe(extract)
|
|
|
|
})
|