{"record":{"id":"3caba1bb2efe5e64","repo":"tonhowtf/omniget","slug":"failed-to-open-zip","errorCode":null,"errorMessage":"Failed to open zip: {}","messagePattern":"Failed to open zip: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/dependencies.rs","lineNumber":586,"sourceCode":"    }\n}\n\nasync fn extract_zip_ffmpeg(\n    archive_path: &std::path::Path,\n    bin_dir: &std::path::Path,\n    ffmpeg_name: &str,\n    ffprobe_name: &str,\n) -> anyhow::Result<()> {\n    let archive_path = archive_path.to_path_buf();\n    let bin_dir = bin_dir.to_path_buf();\n    let ffmpeg_name = ffmpeg_name.to_string();\n    let ffprobe_name = ffprobe_name.to_string();\n\n    tokio::task::spawn_blocking(move || {\n        let file = std::fs::File::open(&archive_path)\n            .map_err(|e| anyhow!(\"Failed to open archive: {}\", e))?;\n        let mut archive =\n            zip::ZipArchive::new(file).map_err(|e| anyhow!(\"Failed to open zip: {}\", e))?;\n\n        let targets = [ffmpeg_name.as_str(), ffprobe_name.as_str()];\n\n        for i in 0..archive.len() {\n            let mut entry = archive\n                .by_index(i)\n                .map_err(|e| anyhow!(\"Failed to read zip entry: {}\", e))?;\n\n            let name = entry.name().to_string();\n            for target in &targets {\n                if name.ends_with(target) {\n                    let dest = bin_dir.join(format!(\"{}.new\", target));\n                    let mut out = std::fs::File::create(&dest)?;\n                    std::io::copy(&mut entry, &mut out)?;\n                    break;\n                }\n            }\n        }","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/dependencies.rs#L568-L604","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the file with `unzip -t` or `file` to confirm it is a genuine ZIP","Confirm the URL serves a .zip and the archive_type in the downloads list is Zip","Delete the temp archive and re-download (network truncation is transient)","Increase integrity checking: compare content-length or checksum before extraction","Free disk space if the temp write was truncated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let mut f = std::fs::File::open(&archive_path)?;\nlet mut sig = [0u8; 4];\nstd::io::Read::read_exact(&mut f, &mut sig)?;\nif &sig != b\"PK\\x03\\x04\" {\n    eprintln!(\"not a ZIP file — mirror served wrong or corrupt payload\");\n}","typeGuard":null,"tryCatchPattern":"match download_ffmpeg().await {\n    Ok(p) => ...,\n    Err(e) if e.to_string().contains(\"Failed to open zip\") => {\n        eprintln!(\"corrupt archive — deleting and re-downloading\");\n        let _ = std::fs::remove_file(&archive_path);\n        re_download().await;\n    }\n    Err(e) => ...,\n}","preventionTips":["Verify ZIP magic bytes or checksum before extraction","Ensure archive_type matches the URL's actual format","Compare content-length against the HTTP header after download","Retry once automatically on zip parse failure — truncation is often transient"],"tags":["archive","zip","download","corruption"],"backgroundTag":"invalid-argument-format","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}