tonhowtf/omniget · error · anyhow::Error

Failed to open zip

Error message

Failed to open zip: {}

What it means

After opening the file, extract_zip_ffmpeg() parses it with zip::ZipArchive::new. If the bytes are not a valid ZIP — corrupt download, HTML error page that passed the size check, or truncated archive — the zip crate error is wrapped in this anyhow message.

Solutions

  1. Verify the file with `unzip -t` or `file` to confirm it is a genuine ZIP
  2. Confirm the URL serves a .zip and the archive_type in the downloads list is Zip
  3. Delete the temp archive and re-download (network truncation is transient)
  4. Increase integrity checking: compare content-length or checksum before extraction
  5. Free disk space if the temp write was truncated
Defensive patterns

Strategy: validation

Validate before calling

let mut f = std::fs::File::open(&archive_path)?;
let mut sig = [0u8; 4];
std::io::Read::read_exact(&mut f, &mut sig)?;
if &sig != b"PK\x03\x04" {
    eprintln!("not a ZIP file — mirror served wrong or corrupt payload");
}

Try / catch

match download_ffmpeg().await {
    Ok(p) => ...,
    Err(e) if e.to_string().contains("Failed to open zip") => {
        eprintln!("corrupt archive — deleting and re-downloading");
        let _ = std::fs::remove_file(&archive_path);
        re_download().await;
    }
    Err(e) => ...,
}

Prevention

When it happens

Trigger: The archive at archive_path is not readable as ZIP: interrupted download, non-ZIP payload (e.g. tar.xz served where zip expected), corrupted bytes, or a password/unsupported-compression ZIP variant.

Common situations: Mirror served an HTML or truncated file; wrong archive_type mapping in the downloads list (zip extraction of a 7z/tar file); flaky network truncating the body; disk full during temp write.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src-tauri/omniget-core/src/core/dependencies.rs:586

    }
}

async fn extract_zip_ffmpeg(
    archive_path: &std::path::Path,
    bin_dir: &std::path::Path,
    ffmpeg_name: &str,
    ffprobe_name: &str,
) -> anyhow::Result<()> {
    let archive_path = archive_path.to_path_buf();
    let bin_dir = bin_dir.to_path_buf();
    let ffmpeg_name = ffmpeg_name.to_string();
    let ffprobe_name = ffprobe_name.to_string();

    tokio::task::spawn_blocking(move || {
        let file = std::fs::File::open(&archive_path)
            .map_err(|e| anyhow!("Failed to open archive: {}", e))?;
        let mut archive =
            zip::ZipArchive::new(file).map_err(|e| anyhow!("Failed to open zip: {}", e))?;

        let targets = [ffmpeg_name.as_str(), ffprobe_name.as_str()];

        for i in 0..archive.len() {
            let mut entry = archive
                .by_index(i)
                .map_err(|e| anyhow!("Failed to read zip entry: {}", e))?;

            let name = entry.name().to_string();
            for target in &targets {
                if name.ends_with(target) {
                    let dest = bin_dir.join(format!("{}.new", target));
                    let mut out = std::fs::File::create(&dest)?;
                    std::io::copy(&mut entry, &mut out)?;
                    break;
                }
            }
        }

View on GitHub (pinned to 8600b91f42)