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

Don't write entire tar file in to memory #1

Open
sts10 opened this issue Jan 12, 2022 · 2 comments
Open

Don't write entire tar file in to memory #1

sts10 opened this issue Jan 12, 2022 · 2 comments

Comments

@sts10
Copy link
Owner

sts10 commented Jan 12, 2022

To speed up performance and lower memory consumption, Bottle should archive, compress and encrypt the contents of a file (tar or otherwise) in chunks when encrypting/decrypting.

Currently, when encrypting a directory, Bottle writes the entire directory's contents to tar file on the file system, then read that tar file back into memory in order to compress it.

https://github.com/sts10/bottle-rs/blob/main/src/lib.rs#L187-L200

Not great! I think attacking this part of the pipeline would be best.

Thankfully, the Builder of the tar crate we're using takes a Writer, so we should be able to make our own Writer impl that directs the tar stream into compression.[1] I'm not sure how to do that yet, so any comments or PRs welcome!

If done right, this will also eliminate the need to write the (unencrypted) tar file to the file system, removing a potential security issue.

After that, we'll have to figure out how to "chunk" the compress-to-encryption pipeline.

(1) Relevant Rust book pages: 178 and in O'Reilly: 428?

@sts10 sts10 changed the title Don't write entire tar file intop memory Don't write entire tar file in to memory Jan 12, 2022
@sts10
Copy link
Owner Author

sts10 commented Jan 14, 2022

c1f0fcb at least makes it so Bottle doesn't write the tar file to the file system when encrypting a directory. It still reads the entire file into memory -- we still need to chunk it.

@sts10
Copy link
Owner Author

sts10 commented Jan 18, 2022

More potentially useful links for me to consult when I'm ready to make another go at this:

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

1 participant