-
Notifications
You must be signed in to change notification settings - Fork 633
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
refactor(archive): A clean implementation of Tar #4538
Conversation
- Incoming chunks of size less than 512 were causing the header to not be aligned properly. - ReadableStreams seem to call the `pull` upon initiation so if the cancel method is called, an extra record was being discarded. - I honestly don't understand how that push property wasn't causing issues before. I guess the chunks I got from Deno.open was always divisible by 512.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please run deno fmt
and ensure the @example
code snippets correctly import symbols? See other code snippets in the codebase for examples.
PTAL @crowlKats |
Sure, but if this is going to be accepted then there are some other things I'd like to implement in it as I realised earlier today it probably should have. For example:
Also if this thing about blobs was implemented in Deno then I'd also like to implement it into the Tar class to make the size property optional. I think that would provide much advantage in situations where a file is being made and you don't actually know its size until the end; where it is just temporarily written to disk behind the scenes and is compatible with other runtimes. |
This seems a breaking change. We need to deprecate the existing API first. Also this seems conflicting with #1985. I think we first need to discuss the direction to take in general |
@BlackAsLight, is it possible to make this a non-breaking change (i.e. pass with existing tests)? |
@iuioiua One of the things not compatible about this implementation to the current one is that this one doesn't allow the user to provide a path to the file on the file system and let the Tar instance get an iterable of it. My preference would be to not support that so it is compatible with other runtimes. Besides that I can't see anything else that can't be changed so its offering the same methods and arguments with maybe slightly different but compatible types. |
as I have stated, this should be a transformstream instead of a class utility, and also this needs to a separate API instead of replacing the current one. Cant just replace the existing one and have different behaviour. |
Nobody asked for this, but since
@std/archive
was still listed as unstable; I thought I'd have a go at rewriting it based off this spec. The tests for this new implementation will need to be written to accommodate the changes, but I thought I wouldn't have a crack at that unless you actually want this.Notes
Some things to note about this implementation.
Iterable
orAsyncIterable
to it. This design choice was to allow the implementation to work in other environments besides Deno, like the browser for instance.Usage Examples
Creating a Tarball
The piping of the readable stream can happen at any stage here. calling
tar.close()
must happen when the user is finished appending files to the instance.Extracting a Tarball
It is important to note for when unarchiving, one must decide to either consume the entirety of the ReadableStream or call cancel (
entry.readable.cancel()
) on it before the next entry will be resolved.It should also be noted here that while compression is optional, it is very easy for the user to implement in their system. This implementation does allow the user to stream their creation and extraction of tarballs all without it ever hitting the file system or creating memory spikes. Granted that the size of each iterable is known.
Anyway, I'd like to know what you think. What you do and don't like.
Edit
TarStream
UnTarStream