tonhowtf/omniget · error
zip invalido
Error message
zip invalido: {} What it means
unpack() extracts downloaded GitHub release archives. For names ending in .zip it opens the bytes with zip::ZipArchive; any parse/open failure (corrupt download, truncated file, non-zip data) is wrapped as 'zip invalido: {}'.
Solutions
- Re-download the asset and verify its digest before unpacking (github::download enforces this)
- Check the first bytes are 'PK' (zip magic) to confirm the payload is actually a zip
- Read the wrapped inner error 'e' in the message for the specific zip failure (e.g. InvalidArchive, UnsupportedArchive)
Defensive patterns
Strategy: validation
Validate before calling
fn looks_like_zip(data: &[u8]) -> bool {
data.starts_with(b"PK")
}
if !looks_like_zip(&data) {
return Err("payload nao e um zip; baixe novamente e verifique o digest".into());
}
github::unpack(&data, name, &dest)?; Try / catch
match github::unpack(&data, name, &dest) {
Err(e) if e.to_string().starts_with("zip invalido") => {
eprintln!("arquivo corrompido; refazendo download...");
let data = github::download(&asset).await?;
github::unpack(&data, name, &dest)?;
}
other => other?,
} Prevention
- Verify the asset digest (github::download already does) before unpacking
- Check zip magic bytes 'PK' as a cheap pre-check
- Clean up partially written downloads on error so retries start fresh
When it happens
Trigger: Calling unpack(data, name, dest) where name ends with .zip but data is not a valid zip: truncated/incomplete download, HTML error page saved as bytes, corrupted transfer.
Common situations: Network interruption mid-download stored as the final file; proxy/captive portal returning an HTML page; asset uploaded incorrectly to the release.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Failed to open zip
- zip invalido
- tar.gz invalido
- tar.xz invalido
- FFmpeg binary not found after extraction
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/ef757202b0b8c613.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/github.rs:117
"[tools] {} veio sem digest; aceito sem verificacao",
asset.name
)
}
None => {
return Err(anyhow!(
"{} veio sem digest da API do GitHub; download descartado",
asset.name
))
}
}
Ok(bytes)
}
pub fn unpack(data: &[u8], name: &str, dest: &Path) -> anyhow::Result<()> {
std::fs::create_dir_all(dest)?;
if name.ends_with(".zip") {
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(data))
.map_err(|e| anyhow!("zip invalido: {}", e))?;
for i in 0..archive.len() {
let mut file = archive.by_index(i)?;
let Some(rel) = file.enclosed_name() else {
continue;
};
let out = dest.join(rel);
if file.is_dir() {
std::fs::create_dir_all(&out)?;
continue;
}
if let Some(parent) = out.parent() {
std::fs::create_dir_all(parent)?;
}
let mut w = std::fs::File::create(&out)?;
std::io::copy(&mut file, &mut w)?;
}
Ok(())
} else if name.ends_with(".tar.gz") || name.ends_with(".tgz") {View on GitHub (pinned to 8600b91f42)