Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a contentsByteOffset to the header emitted on entry events. #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class Extract extends Writable {

if (!this._header) return true

this._header.byteOffset = this._buffer.shifted

switch (this._header.type) {
case 'gnu-long-path':
case 'gnu-long-link-path':
Expand Down
1 change: 1 addition & 0 deletions headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ exports.decode = function decode (buf, filenameEncoding, allowUnknownFormat) {
uid,
gid,
size,
byteOffset: 0,
mtime: new Date(1000 * mtime),
type,
linkname,
Expand Down
18 changes: 18 additions & 0 deletions test/extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test('one-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -54,6 +55,7 @@ test('chunked-one-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -104,6 +106,7 @@ test('multi-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand All @@ -128,6 +131,7 @@ test('multi-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 1536,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -171,6 +175,7 @@ test('chunked-multi-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand All @@ -195,6 +200,7 @@ test('chunked-multi-file', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 1536,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -226,6 +232,7 @@ test('pax', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 1536,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -271,6 +278,7 @@ test('types', function (t) {
uid: 501,
gid: 20,
size: 0,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'directory',
linkname: null,
Expand All @@ -297,6 +305,7 @@ test('types', function (t) {
uid: 501,
gid: 20,
size: 0,
byteOffset: 1024,
mtime: new Date(1387580181000),
type: 'symlink',
linkname: 'directory',
Expand Down Expand Up @@ -330,6 +339,7 @@ test('long-name', function (t) {
uid: 501,
gid: 20,
size: 16,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -367,6 +377,7 @@ test('unicode-bsd', function (t) { // can unpack a bsdtar unicoded tarball
uid: 501,
gid: 20,
size: 4,
byteOffset: 1536,
mtime: new Date(1387588646000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -404,6 +415,7 @@ test('unicode', function (t) { // can unpack a bsdtar unicoded tarball
uid: 501,
gid: 20,
size: 8,
byteOffset: 1536,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -521,6 +533,7 @@ test('base 256 size', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -554,6 +567,7 @@ test('latin-1', function (t) { // can unpack filenames encoded in latin-1
uid: 0,
gid: 0,
size: 14,
byteOffset: 512,
mtime: new Date(1495941034000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -611,6 +625,7 @@ test('gnu', function (t) { // can correctly unpack gnu-tar format
uid: 12345,
gid: 67890,
size: 14,
byteOffset: 512,
mtime: new Date(1559239869000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -652,6 +667,7 @@ test('gnu-incremental', function (t) {
uid: 12345,
gid: 67890,
size: 14,
byteOffset: 512,
mtime: new Date(1559239869000),
type: 'file',
linkname: null,
Expand Down Expand Up @@ -723,6 +739,7 @@ test('unknown format attempts to extract if allowed', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 512,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand All @@ -747,6 +764,7 @@ test('unknown format attempts to extract if allowed', function (t) {
uid: 501,
gid: 20,
size: 12,
byteOffset: 1536,
mtime: new Date(1387580181000),
type: 'file',
linkname: null,
Expand Down