{"record":{"id":"e9026cb092cee112","repo":"tonhowtf/omniget","slug":"only-of-segments-were-written","errorCode":null,"errorMessage":"Only {} of {} segments were written","messagePattern":"Only (.+?) of (.+?) segments were written","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/hls_downloader.rs","lineNumber":692,"sourceCode":"                    buf.drain(..payload_start);\n                }\n                let decryptor = Aes128CbcDec::new_from_slices(&enc.key_bytes, &iv)\n                    .map_err(|e| anyhow::anyhow!(\"AES init: {:?}\", e))?;\n                let decrypted = decryptor\n                    .decrypt_padded_mut::<Pkcs7>(&mut buf)\n                    .map_err(|e| anyhow::anyhow!(\"AES decrypt: {:?}\", e))?;\n                file.write_all(decrypted)?;\n            } else {\n                file.write_all(&segment_data[payload_start..])?;\n            }\n            next_expected += 1;\n        }\n    }\n\n    file.flush()?;\n\n    if next_expected < total_segments {\n        anyhow::bail!(\n            \"Only {} of {} segments were written\",\n            next_expected,\n            total_segments\n        );\n    }\n\n    Ok(())\n}\n\nconst SEGMENT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);\n\nasync fn download_segment_with_retry(\n    client: &Client,\n    url: &str,\n    referer: &str,\n    user_agent: &str,\n    max_retries: u32,\n    cancel: &CancellationToken,","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/hls_downloader.rs#L674-L710","documentation":"Integrity check in write_segments_ordered: after draining the reassembly buffer, fewer segments than the playlist declared were successfully written — gaps in the sequence mean the output would be corrupt, so the partial file is rejected instead of shipped.","triggerScenarios":"Thrown at src-tauri/omniget-core/src/core/hls_downloader.rs:692 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the download; missing segments are usually transient network failures","Increase segment retry count and concurrency resilience","Verify the playlist was not modified mid-download (VOD vs live mismatch)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}