tonhowtf/omniget · error

tar.gz invalido

Error message

tar.gz invalido: {}

What it means

Archive failure in unpack: the downloaded .tar.gz/.tgz could not be decompressed or unpacked by the flate2+tar pipeline — the bytes are truncated, corrupt, or not actually gzip, so extraction is aborted.

Solutions

  1. Re-download and verify digest before unpacking
  2. Confirm the file starts with gzip magic bytes (1f 8b)
  3. Read the wrapped inner error for the specific gzip/tar failure
Defensive patterns

Strategy: validation

Validate before calling

fn looks_like_gzip(data: &[u8]) -> bool {
    data.starts_with(&[0x1f, 0x8b])
}
if !looks_like_gzip(&data) {
    return Err("payload nao e gzip; baixe novamente".into());
}
github::unpack(&data, name, &dest)?;

Try / catch

match github::unpack(&data, name, &dest) {
    Err(e) if e.to_string().starts_with("tar.gz invalido") => {
        eprintln!("download corrompido; refazendo...");
        let data = github::download(&asset).await?;
        github::unpack(&data, name, &dest)?;
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling unpack() with a .tar.gz/.tgz name whose bytes are corrupt: truncated gzip stream, bad CRC, or data that isn't gzip at all.

Common situations: Partial download; asset that is plain tar misnamed as .tar.gz; decompression of an HTML error page saved as the asset.

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


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/2abd7ef43a8f9b63. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/github.rs:141

            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") {
        let decoder = flate2::read::GzDecoder::new(std::io::Cursor::new(data));
        let mut archive = tar::Archive::new(decoder);
        archive.set_preserve_permissions(true);
        archive
            .unpack(dest)
            .map_err(|e| anyhow!("tar.gz invalido: {}", e))
    } else if name.ends_with(".tar.xz") {
        let decoder = xz2::read::XzDecoder::new(std::io::Cursor::new(data));
        let mut archive = tar::Archive::new(decoder);
        archive.set_preserve_permissions(true);
        archive
            .unpack(dest)
            .map_err(|e| anyhow!("tar.xz invalido: {}", e))
    } else {
        Err(anyhow!("formato de pacote desconhecido: {}", name))
    }
}

/// Procura um arquivo pelo nome dentro de uma árvore (os zips do whisper.cpp
/// e do Real-ESRGAN têm subpastas diferentes por plataforma).
pub fn find_file(root: &Path, file_name: &str) -> Option<PathBuf> {
    let mut stack = vec![root.to_path_buf()];
    while let Some(dir) = stack.pop() {
        let Ok(rd) = std::fs::read_dir(&dir) else {

View on GitHub (pinned to 8600b91f42)