{"record":{"id":"b0d93968b75deea0","repo":"tonhowtf/omniget","slug":"failed-to-read-tar-entry","errorCode":null,"errorMessage":"Failed to read tar entry: {}","messagePattern":"Failed to read tar entry: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/dependencies.rs","lineNumber":636,"sourceCode":"    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 decompressor = xz2::read::XzDecoder::new(file);\n        let mut archive = tar::Archive::new(decompressor);\n        let targets = [ffmpeg_name.as_str(), ffprobe_name.as_str()];\n\n        for entry_result in archive\n            .entries()\n            .map_err(|e| anyhow!(\"Failed to read tar entries: {}\", e))?\n        {\n            let mut entry = entry_result.map_err(|e| anyhow!(\"Failed to read tar entry: {}\", e))?;\n            let path = entry\n                .path()\n                .map_err(|e| anyhow!(\"Failed to read entry path: {}\", e))?;\n            let file_name = path.file_name().and_then(|n| n.to_str()).unwrap_or(\"\");\n            for target in &targets {\n                if file_name == *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        }\n        Ok::<(), anyhow::Error>(())\n    })\n    .await\n    .map_err(|e| anyhow!(\"Spawn blocking failed: {}\", e))??;\n    Ok(())","sourceCodeStart":618,"sourceCodeEnd":654,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/dependencies.rs#L618-L654","documentation":"While iterating tar entries in extract_tar_xz_ffmpeg, each individual entry_result is unwrapped; a per-entry error (I/O read failure while advancing the stream, malformed header for that member) is wrapped as 'Failed to read tar entry'. entries() yields Err for the bad member and iteration then stops.","triggerScenarios":"Corrupt or truncated xz/tar stream hit at a specific member boundary; unreadable data block; a member header with invalid checksum or encoding that the tar crate rejects.","commonSituations":"Partial download where the tail of the archive is cut off; disk read errors; archives produced by tools emitting nonstandard headers the tar crate refuses.","solutions":["Re-download the archive and retry extraction","Validate the archive with an external tool (xz -t file.tar.xz; tar -tf) to confirm corruption","Log which entry index failed to identify the corruption point","Verify available disk space; ENOSPC surfaces as read/write errors during iteration"],"exampleFix":"// before\nlet mut entry = entry_result.map_err(|e| anyhow!(\"Failed to read tar entry: {}\", e))?;\n// after\nlet mut entry = entry_result.map_err(|e| anyhow!(\"Failed to read tar entry (archive likely truncated/corrupt, re-download): {}\", e))?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// validate archive integrity beforehand with xz2 streaming decode\nmatch extract_tar_xz_ffmpeg(&path, &bin, &ff, &fprobe).await {\n    Err(e) if e.to_string().contains(\"Failed to read tar entry\") => {\n        eprintln!(\"archive corrupt mid-stream, re-downloading\");\n        std::fs::remove_file(&path).ok();\n        // re-download and retry once\n    },\n    r => r?,\n}","preventionTips":["Verify archive checksum/size before extraction","Ensure stable network or resumable downloads to avoid truncation","Check free disk space before unpacking","Validate the full xz stream with xz2::read::XzDecoder before handing to tar"],"tags":["tar","archive-extraction","corrupt-file"],"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"}