Majored / rs-async-zip

An asynchronous ZIP archive reading/writing crate.
MIT License
131 stars 44 forks source link

Error reading archive #64

Closed sidred closed 1 year ago

sidred commented 1 year ago

Unable to read an archive using the code

    let mut file = tokio::fs::File::open(zip_file).await.unwrap();
    let mut zip = ZipFileReader::new(&mut file).await.unwrap();

    let entry = zip.file().entries().get(0).unwrap().clone();
    let mut string = String::new();
    let mut reader = zip.entry(0).await.unwrap();
    let txt = reader.read_to_string_checked(&mut string, entry.entry()).await.unwrap();
    println!("{}", txt);

Error is

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UpstreamReadError(Custom { kind: InvalidData, error: "stream did not contain valid UTF-8" })'

This happens on a simple zip file with two files (a.txt and b.txt) having content

01234567890123456789012345678901234567890123456789

Extracting the zip file without crc check shows the content of a.txt as

45678901234567890123456789
PK
�����XC0V‹4^3���3�

Looks like a regression in v0.0.10. Works correctly in v0.0.9

Majored commented 1 year ago

This should be solved with https://github.com/Majored/rs-async-zip/pull/61.

I'll make a new release pretty soon because it seems like this affects all the seeking readers which I should've checked before pushing 0.0.10, so that's my bad.

If you could provide the ZIP file you used or clone the repo locally to test whether that PR fixes it, that would be helpful.

sidred commented 1 year ago

Yeah seems to work with current master. Let me see if i can come up with a quick test case for this.

Majored commented 1 year ago

@sidred I've released v0.0.11 if that's any help to you. 😄