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

Feeding a Builder parts of a file at a time #149

Open
jjl opened this issue Apr 3, 2018 · 13 comments
Open

Feeding a Builder parts of a file at a time #149

jjl opened this issue Apr 3, 2018 · 13 comments

Comments

@jjl
Copy link

jjl commented Apr 3, 2018

Currently, so far as I can tell, it's not possible to stream a file's contents as it becomes available - it is necessary to read an entire file into memory at a time to add it to an archive.

It would be awesome if it were possible to build up an entry's body incrementally, such as in response to filesystem events from tokio.

@alexcrichton
Copy link
Owner

The append method takes a Read, would that suffice for this?

@jjl
Copy link
Author

jjl commented Apr 3, 2018

It's entirely possible I'm wrong about this, but I think that would block up the tokio event loop?

@alexcrichton
Copy link
Owner

Ah no yeah that's true, this library is not currently compatible with async I/O

@jjl
Copy link
Author

jjl commented Apr 3, 2018

I'd be willing to put in the effort to make it so, if you've got ideas about how it might be done.

@alexcrichton
Copy link
Owner

Hm sure! I haven't put a lot of thought into how this library would support futures and async I/O but my guess is that it'd be relatively low-level. It might be the case that we need to basically just add a new append method that attempts to write data after the header is written and returns how much was written, basically being compatible with "would block"

@jjl
Copy link
Author

jjl commented Apr 3, 2018

That sounds plausible for a first start. It would be nice to get recursive directory adding etc. working with async too if the user opts into it (tokio feature flag like your flate2 crate?)

@alexcrichton
Copy link
Owner

Seems plausible to me!

@jjl
Copy link
Author

jjl commented Apr 29, 2018

I've had a go at something slightly better (imo) than this initial solution, but I can't quite finish it because I'm slightly confused by what this code (from prepare_header) is doing:

        let mut data2 = data.chain(io::repeat(0).take(0));
        append(dst, &header2, &mut data2)?;

In particular, does chaining .take(0) not make this a noop?

@alexcrichton
Copy link
Owner

Oh dear that is odd! That can probably be removed now, it may just be something that didn't survive refactorings well

@ghost
Copy link

ghost commented Mar 18, 2019

Is there any news on this?

@jjl
Copy link
Author

jjl commented Mar 18, 2019 via email

@the8472
Copy link

the8472 commented Apr 19, 2019

Passing the data in parts would also be necessary to build sparse files.

@danieleades
Copy link
Contributor

it would be pretty handy if async interop was a thing that existed

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

No branches or pull requests

4 participants