Skip to content

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

Open
doxavore wants to merge 2 commits intomafintosh:masterfrom
doxavore:contents-byte-offset-in-header
Open

Add a contentsByteOffset to the header emitted on entry events.#170
doxavore wants to merge 2 commits intomafintosh:masterfrom
doxavore:contents-byte-offset-in-header

Conversation

@doxavore
Copy link
Copy Markdown

When emitting the header for an entry event, the contentsByteOffset property is added to the header object. This property is the byte offset of the start of the entry's file contents in the tar stream, after the header.

This is useful when building an index of a tar's contents, for later seeking to a specific entry's contents in the tar stream.

Headers can be variable length based on the tar implementation.

Fixes #162. I'm happy to change this if we prefer a different approach.

When emitting the header for an entry event, the contentsByteOffset
property is added to the header object. This property is the byte offset
of the start of the entry's file contents in the tar stream, after
the header.

This is useful when building an index of a tar's contents, for later
seeking to a specific entry's contents in the tar stream.

Headers can be variable length based on the tar implementation.
extract.js Outdated

this._stream = this._createStream()
this._missing = this._header.size
const header = { ...this._header, contentsByteOffset: this._buffer.shifted }
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can name it byteOffset just, similar to how that property is normally used.

in headers.decode, just declare it there and init it to 0, then simply mutate it in here instead of the spread

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied these changes. Thank you! 🙏

@mafintosh
Copy link
Copy Markdown
Owner

nice, commented

@doxavore doxavore requested a review from mafintosh January 15, 2025 15:10
@doxavore
Copy link
Copy Markdown
Author

doxavore commented Mar 6, 2025

@mafintosh Do you have any feedback on my changes, or is there anything I can do to help get this merged? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is it possible to return raw file offsets from within the tar?

2 participants