-
Notifications
You must be signed in to change notification settings - Fork 192
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 way to use Builder in append mode, that would not write empty blocks on the end of the archive #227
Comments
Thanks for the report! I'm not really sure I fully understand what's going on here, though? Can you perhaps give an example of where this might help things? |
Sorry, it seems I really wasn't clear in the initial report. Maybe this code can explain it better:
Of course it is simplified, e.g. it assumes that buf is big enough to handle one document or even [0;1024] at once, but I hope it shows the intention. The 'problem' is quite easy to work around but still having opt-out from finish in |
Hm I'm still not sure I entirely understand. Is the idea that you want to use |
Yes, exactly
Unless I miss something - no, at least without additional memory. I would need to store It sounds unnecessary IMO, especially that all underlying operations are exposed by the crate so I can do it efficiently already, just in a more verbose, less convenient way. |
Ah ok makes sense. Given that the |
I've very recently used this library to stream tar.gz output using Rocket. While I was able to do this pretty easily, I had to give up using
tar::Builder
only because it forces me to callfinish
in all destructors (e.g.drop
orinto_inner
).Imagine, that I have
StreamedBody
struct that implementsRead
. Inread
, it loads some resources (for example from the DB or file system) and archives them using tar. Since it loads only data chunk, it also has to produce a chunk of tar = header + data. There is greattar::Builder::append_data
method butBuilder
has to live only insideRead::read
, otherwise I run into borrowing issues (Builder
holds a reference to a buffer. In my example, bothBuilder
and buffer would be fields ofStreamedBody
which is not easily achievable)drop
, every time a chunk is archived, the end of archive mark is written.I think we could add
tar::Builder::continuous(&mut self)
that would set a flag and then intar::Builder::finish
we could only write empty blocks if continuous == false.The text was updated successfully, but these errors were encountered: