{"record":{"id":"554c4a7ab13ce776","repo":"tonhowtf/omniget","slug":"aria2c-falhou","errorCode":null,"errorMessage":"aria2c falhou: {}","messagePattern":"aria2c falhou: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/aria2.rs","lineNumber":128,"sourceCode":"    let id2 = id.clone();\n    let task = tokio::spawn(async move {\n        let mut last = String::new();\n        if let Some(o) = stdout {\n            let mut lines = BufReader::new(o).lines();\n            while let Ok(Some(line)) = lines.next_line().await {\n                if let Some((pct, speed)) = parse_progress(&line) {\n                    super::report(&p2, &id2, \"progress\", pct, Some(100), Some(speed));\n                } else if !line.trim().is_empty() {\n                    last = line;\n                }\n            }\n        }\n        last\n    });\n    let st = child.wait().await?;\n    let last = task.await.unwrap_or_default();\n    if !st.success() {\n        return Err(anyhow!(\"aria2c falhou: {}\", last));\n    }\n    // aria2 decide o nome pelo Content-Disposition/URL; pega o arquivo mais novo da pasta\n    let path = if !opts.file_name.trim().is_empty() {\n        PathBuf::from(&opts.dest_dir).join(opts.file_name.trim())\n    } else {\n        std::fs::read_dir(&opts.dest_dir)?\n            .flatten()\n            .filter(|e| e.path().is_file() && !e.path().to_string_lossy().ends_with(\".aria2\"))\n            .max_by_key(|e| e.metadata().and_then(|m| m.modified()).ok())\n            .map(|e| e.path())\n            .ok_or_else(|| anyhow!(\"download terminou mas nao achei o arquivo\"))?\n    };\n    let bytes = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0);\n    super::report(&progress, &id, \"done\", 100, Some(100), None);\n    Ok(Aria2Result {\n        path: path.to_string_lossy().to_string(),\n        bytes,\n    })","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/aria2.rs#L110-L146","documentation":"After spawning aria2c, download() awaits the child's exit status and, if it exited non-zero, fails with this message carrying the last progress/status line aria2c printed on stdout. The process ran but the download itself failed.","triggerScenarios":"opts.url unreachable or returning HTTP 4xx/5xx, disk full or dest_dir unwritable, invalid aria2c options, .aria2 control-file corruption, or any other non-zero aria2c exit.","commonSituations":"Dead or renamed download URL; 403 from a host requiring cookies/headers aria2c wasn't given; disk quota exceeded; user interrupting download leaving a corrupt .aria2 control file; wrong URL scheme for aria2c.","solutions":["Inspect the embedded `last` line in the message — it contains aria2c's own status (e.g. error code, HTTP status) and points to the root cause.","Open opts.url in a browser/curl to confirm the resource still exists and is reachable.","Delete stale `*.aria2` control files in dest_dir and retry.","Check free disk space and write permissions on opts.dest_dir."],"exampleFix":"// before\nif !st.success() {\n    return Err(anyhow!(\"aria2c falhou: {}\", last));\n}\n// after\nif !st.success() {\n    let code = st.code().map(|c| c.to_string()).unwrap_or_else(|| \"signal\".into());\n    return Err(anyhow!(\"aria2c falhou (exit {code}): {} | url={}\", last, opts.url));\n}","handlingStrategy":"retry","validationCode":"// pre-check\nlet resp = reqwest::get(&opts.url).await?;\nif !resp.status().is_success() { bail!(\"URL indisponivel: {}\", resp.status()); }\n// plus: disk space check on dest_dir before starting","typeGuard":null,"tryCatchPattern":"let mut attempts = 0;\nloop {\n    match aria2::download(opts.clone()).await {\n        Err(e) if e.to_string().contains(\"aria2c falhou\") && attempts < 2 => {\n            attempts += 1;\n            tokio::time::sleep(Duration::from_secs(2 * attempts)).await;\n            // limpa arquivos .aria2 de controle antes de tentar de novo\n        }\n        other => break other,\n    }\n}","preventionTips":["Always log the aria2c status line embedded in the error; it names the root cause (HTTP code, disk error).","Pre-validate the URL returns 200 before spawning aria2c.","Clean up stale *.aria2 control files between retries.","Monitor disk space on dest_dir for large downloads."],"tags":["download","aria2","nonzero-exit","network"],"backgroundTag":"http-error-response","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"}