{"record":{"id":"0a378db234b0cfb2","repo":"tonhowtf/omniget","slug":"tar-xz-invalido","errorCode":null,"errorMessage":"tar.xz invalido: {}","messagePattern":"tar\\.xz invalido: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/github.rs","lineNumber":148,"sourceCode":"            }\n            let mut w = std::fs::File::create(&out)?;\n            std::io::copy(&mut file, &mut w)?;\n        }\n        Ok(())\n    } else if name.ends_with(\".tar.gz\") || name.ends_with(\".tgz\") {\n        let decoder = flate2::read::GzDecoder::new(std::io::Cursor::new(data));\n        let mut archive = tar::Archive::new(decoder);\n        archive.set_preserve_permissions(true);\n        archive\n            .unpack(dest)\n            .map_err(|e| anyhow!(\"tar.gz invalido: {}\", e))\n    } else if name.ends_with(\".tar.xz\") {\n        let decoder = xz2::read::XzDecoder::new(std::io::Cursor::new(data));\n        let mut archive = tar::Archive::new(decoder);\n        archive.set_preserve_permissions(true);\n        archive\n            .unpack(dest)\n            .map_err(|e| anyhow!(\"tar.xz invalido: {}\", e))\n    } else {\n        Err(anyhow!(\"formato de pacote desconhecido: {}\", name))\n    }\n}\n\n/// Procura um arquivo pelo nome dentro de uma árvore (os zips do whisper.cpp\n/// e do Real-ESRGAN têm subpastas diferentes por plataforma).\npub fn find_file(root: &Path, file_name: &str) -> Option<PathBuf> {\n    let mut stack = vec![root.to_path_buf()];\n    while let Some(dir) = stack.pop() {\n        let Ok(rd) = std::fs::read_dir(&dir) else {\n            continue;\n        };\n        for entry in rd.flatten() {\n            let p = entry.path();\n            if p.is_dir() {\n                stack.push(p);\n            } else if p.file_name().map(|n| n == file_name).unwrap_or(false) {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/github.rs#L130-L166","documentation":"Extraction failure wrapper in the GitHub asset unpacker: when the downloaded asset name ends with .tar.gz or .tgz, the archive is decoded with GzDecoder and unpacked into dest; if tar::Archive::unpack fails (corrupt gzip stream, malformed tar member, I/O error writing into dest, permission problem), the raw error is remapped to this message with the underlying error in {}. It fires only for the tar.gz/tgz branch of unpack — a bad or truncated archive or an unwritable destination.","triggerScenarios":"Calling unpack() with a .tar.xz name whose bytes fail xz decompression or tar extraction: truncated stream, corrupt xz frame, or non-xz payload.","commonSituations":"Interrupted downloads of large xz archives; release asset replaced/re-compressed between download and unpack; mislabeled payload that is actually .tar.gz.","solutions":["Re-download and verify the digest before unpacking","Confirm the payload starts with xz magic (FD 37 7A 58 5A 00)","If the project actually ships .tar.gz, unpack with the matching name instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn looks_like_xz(data: &[u8]) -> bool {\n    data.starts_with(&[0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])\n}\nif !looks_like_xz(&data) {\n    return Err(\"payload nao e xz; confira o nome e o conteudo do asset\".into());\n}\ngithub::unpack(&data, name, &dest)?;","typeGuard":null,"tryCatchPattern":"match github::unpack(&data, name, &dest) {\n    Err(e) if e.to_string().starts_with(\"tar.xz invalido\") => {\n        eprintln!(\"download corrompido ou nome errado; refazendo...\");\n        let data = github::download(&asset).await?;\n        github::unpack(&data, name, &dest)?;\n    }\n    other => other?,\n}","preventionTips":["Verify digest before unpack; a truncated xz stream is the usual cause","Check xz magic bytes FD 37 7A 58 5A 00 as a pre-check","Make sure the asset name matches its actual compression (don't pass .tar.gz bytes with a .tar.xz name)"],"tags":["github","tar","xz","archive"],"backgroundTag":"file-read-failed","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"}