-
Notifications
You must be signed in to change notification settings - Fork 232
Binary file seems to be corrupted with method Deflated #378
Comments
|
But I found neither of the following supports ZStandard:
|
Just ran into this also. Have to use |
You are using https://doc.rust-lang.org/stable/std/io/trait.Write.html#tymethod.write
|
Oh, It was fixed! Thank you! |
I'm using |
@milesj I thought I want to use |
When I try that I get this error "stream did not contain valid UTF-8", which is the same as using Both are interesting, since these test cases are very simple. I also tried this, which failed with the same error.
I feel like something else may be going on. |
I tried this. /// Succeeds🌔
fn diagnose_1(path: &str) {
let data = std::fs::read(path).unwrap();
println!("(1) {} is {} bytes.", path, data.len());
}
/// Succeeds🌔
fn diagnose_2(path: &str) {
use std::io::Read;
let mut file = std::fs::File::open(path).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
println!("(2) {} is {} bytes.", path, buffer.len());
}
/// Fails🌒
fn diagnose_3(path: &str) {
let text = std::fs::read_to_string(path).unwrap(); // 🔥stream did not contain valid UTF-8
let data = text.as_bytes();
println!("(3) {} is {} bytes.", path, data.len());
}
pub fn main() {
diagnose_1(r"C:\Windows\system32\notepad.exe"); //🌔
diagnose_2(r"C:\Windows\system32\notepad.exe"); //🌔
diagnose_3(r"C:\Windows\system32\notepad.exe"); //🌒
} Result was
|
It's weird, because even if I do this it fails: self.archive
.start_file(name, options)
.map_err(|error| ZipError::AddFailure {
source: file.to_path_buf(),
error,
})?;
self.archive
.write_all(&std::fs::read(file).unwrap())
.map_err(|error| FsError::Write {
path: file.to_path_buf(),
error,
})?; I wonder if this abstraction is causing issues once compiled. Example PR: moonrepo/starbase#33 |
@milesj What kind of file is broken or fail? |
Not sure which file is the problem, but this is the fixture: https://github.com/moonrepo/starbase/tree/master/crates/archive/tests/__fixtures__/archives They are very simple files. |
I figured out the problem, was my mistake. The issue was I was using I'm using Copilot and I think it generated that 😞 |
That's good! Everything has become clear. |
Summary
Binary file seems to be corrupted with method
zip::CompressionMethod::Deflated
.Code to reproduce
Result is
Thank you!
The text was updated successfully, but these errors were encountered: