rust-lang / flate2-rs

DEFLATE, gzip, and zlib bindings for Rust
https://docs.rs/flate2
Apache License 2.0
929 stars 163 forks source link

basic tar encode + decode failure #334

Closed verrchu closed 1 year ago

verrchu commented 1 year ago

I am sure I am doing something wrong but I don't know what exactly

the code on the playground works fine untill you substittue reader and writer to the commented ones which use Gz{En,De}coder https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=59fafd2fdf1dc39e6f71908cba87b070

deps: tar = 3.3.0 flate2 = 1.0.25 tar = 0.4.38

verrchu commented 1 year ago

ok now this works https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b193c20f3ccb6b6b628d165d394da174

apparently dropping builder ofter writing an archive solves the problem

jongiddy commented 1 year ago

The GzEncoder works similarly to the tar::Builder. You need to call its finish method when all content has been written. Dropping the GzEncoder does this, but you can get the same effect using builder.into_inner()?.finish()?;

JohnTitor commented 1 year ago

Closing in favor of the above comment, thanks!