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

create zip file failed with append mode #160

Open
KveinAxel opened this issue Jan 11, 2024 · 2 comments
Open

create zip file failed with append mode #160

KveinAxel opened this issue Jan 11, 2024 · 2 comments

Comments

@KveinAxel
Copy link

use std::fs::OpenOptions;

fn main() {
    let mut zip = zip::ZipWriter::new(
        OpenOptions::new()
            .append(true)
            .create(true)
            .open("test.zip")
            .unwrap(),
    );

    let options =
        zip::write::FileOptions::default().compression_method(zip::CompressionMethod::Stored);
    zip.start_file("hello_world.txt", options).unwrap();

    zip.finish().unwrap();
}

as title, if we create a zip with append mode, it will fail to be unzip

image

it seems like some zero bytes were not cleared.
image

I'm sure the file is new created, not run multile times.

@KveinAxel KveinAxel changed the title crate zip file failed with append mode create zip file failed with append mode Jan 11, 2024
@a1phyr
Copy link
Contributor

a1phyr commented Apr 9, 2024

I am pretty sure the append(true) on the file is the culprit here. Can you try without ?

@Pr0methean
Copy link
Member

Pr0methean commented May 6, 2024

Try changing it to write(true); that'll be more convenient to test since it will overwrite any previous version.

@Pr0methean Pr0methean transferred this issue from zip-rs/zip-old Jun 2, 2024
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

3 participants