{"record":{"id":"5dd12cd18e1186cf","repo":"tonhowtf/omniget","slug":"tar-gz-invalido","errorCode":null,"errorMessage":"tar.gz invalido: {}","messagePattern":"tar\\.gz invalido: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/spicetify.rs","lineNumber":494,"sourceCode":"            std::fs::create_dir_all(&out)?;\n            continue;\n        }\n        if let Some(parent) = out.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n        let mut w = std::fs::File::create(&out)?;\n        std::io::copy(&mut file, &mut w)?;\n    }\n    Ok(())\n}\n\nfn unpack_tar_gz(data: &[u8], dest: &Path) -> anyhow::Result<()> {\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    Ok(())\n}\n\n#[cfg(unix)]\nfn make_executable(path: &Path) {\n    use std::os::unix::fs::PermissionsExt;\n    let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o755));\n}\n\n#[cfg(not(unix))]\nfn make_executable(_path: &Path) {}\n\n/// Baixa o último release do CLI para `<app_data>/bin/spicetify-cli/`.\n/// A pasta antiga só sai depois que a nova está inteira no disco.\npub async fn install() -> anyhow::Result<PathBuf> {\n    if dependencies::is_flatpak() {\n        return Err(anyhow!(\n            \"dentro do Flatpak o Spicetify nao consegue alterar o Spotify do sistema\"","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/spicetify.rs#L476-L512","documentation":"`unpack_tar_gz` gunzips and extracts the downloaded tarball (Linux/macOS Spicetify CLI) with flate2 + tar. If decompression or extraction fails — bad gzip magic, truncated data, invalid tar structure, or an unwritable destination — the error is wrapped as this message. Note the same message covers destination I/O errors too, not just malformed archives.","triggerScenarios":"`unpack_tar_gz(data, dest)` where GzDecoder/archive.unpack fails: non-gzip bytes (HTML error page), truncated download, corrupted tar entries, or `dest` missing/unwritable.","commonSituations":"Proxy injecting HTML into the download; interrupted download; extracting into a directory that was deleted or has wrong permissions; disk full.","solutions":["Re-download the tarball and verify the digest before unpacking","Check the first two bytes — `\\x1f\\x8b` is gzip; HTML/text means the download captured an error page","Ensure `dest` exists, is a directory, and is writable (`mkdir -p`, check permissions)","Check free disk space and that no file inside the archive is locked by another process"],"exampleFix":"// before\nunpack_tar_gz(&data, &dest)?;\n// after\nif !data.starts_with(&[0x1f, 0x8b]) {\n    anyhow::bail!(\"download is not gzip (proxy/error page?) — re-download\");\n}\nstd::fs::create_dir_all(&dest)?;\nunpack_tar_gz(&data, &dest)?;","handlingStrategy":"validation","validationCode":"fn looks_like_gzip(data: &[u8]) -> bool { data.starts_with(&[0x1f, 0x8b]) }\n// call before unpack_tar_gz:\nstd::fs::create_dir_all(&dest)?;\nif !looks_like_gzip(&data) { re_download().await?; }","typeGuard":"fn is_gzip(data: &[u8]) -> bool { data.len() > 2 && data[0] == 0x1f && data[1] == 0x8b }","tryCatchPattern":"match unpack_tar_gz(&data, &dest) {\n    Err(e) if e.to_string().contains(\"tar.gz invalido\") => {\n        std::fs::create_dir_all(&dest)?; // rule out missing dest\n        let fresh = download_verified(&client, &asset).await?;\n        unpack_tar_gz(&fresh, &dest)\n    }\n    other => other,\n}","preventionTips":["Verify the gzip magic bytes and digest before unpacking","Ensure the destination directory exists and is writable before extraction","Re-download on mismatch — the error often means an HTML error page was captured","Check free disk space for large archives"],"tags":["archive","tar","gzip"],"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"}