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

Produced GNU Sparse File (aka 'GNUSparseFile.0') instead of unpacked .tar.gz #314

Closed chshersh closed 2 years ago

chshersh commented 2 years ago

I'm using flate2 in my Cargo.toml like this:

flate2 = "1.0"

When I'm trying to unpack tokei-x86_64-apple-darwin.tar.gz using the following code:

fn unpack_tar(tar_path: &PathBuf, tmp_dir: &Path) -> Result<(), std::io::Error> {
    let tar_file = File::open(tar_path)?;
    let tar_decoder = GzDecoder::new(tar_file);
    let mut archive = tar::Archive::new(tar_decoder);
    archive.unpack(tmp_dir)
}

I see that the unpacking result produces the GNUSparseFile.0 directory:

$ exa --tree
.
├── GNUSparseFile.0
│  └── tokei
└── tokei-x86_64-apple-darwin.tar.gz

I'm not sure if the file actually valid (since I'm on Ubuntu 20.04 and the archive contents a macOS executable so I can't run it). But is this expected and can/should it be fixed?

chshersh commented 2 years ago

Seems to be an issue in the tar crate:

Closing in favour of the issue in another repository. But maybe it'll help somebody to discover it 😌