tonhowtf/omniget · error
aria2c falhou
Error message
aria2c falhou: {} What it means
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.
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.
Example fix
// before
if !st.success() {
return Err(anyhow!("aria2c falhou: {}", last));
}
// after
if !st.success() {
let code = st.code().map(|c| c.to_string()).unwrap_or_else(|| "signal".into());
return Err(anyhow!("aria2c falhou (exit {code}): {} | url={}", last, opts.url));
} Defensive patterns
Strategy: retry
Validate before calling
// pre-check
let resp = reqwest::get(&opts.url).await?;
if !resp.status().is_success() { bail!("URL indisponivel: {}", resp.status()); }
// plus: disk space check on dest_dir before starting Try / catch
let mut attempts = 0;
loop {
match aria2::download(opts.clone()).await {
Err(e) if e.to_string().contains("aria2c falhou") && attempts < 2 => {
attempts += 1;
tokio::time::sleep(Duration::from_secs(2 * attempts)).await;
// limpa arquivos .aria2 de controle antes de tentar de novo
}
other => break other,
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- download falhou: HTTP
- download de falhou: HTTP
- Torrent download failed
- Failed to download attachment
- nao foi possivel buscar
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/554c4a7ab13ce776.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/aria2.rs:128
let id2 = id.clone();
let task = tokio::spawn(async move {
let mut last = String::new();
if let Some(o) = stdout {
let mut lines = BufReader::new(o).lines();
while let Ok(Some(line)) = lines.next_line().await {
if let Some((pct, speed)) = parse_progress(&line) {
super::report(&p2, &id2, "progress", pct, Some(100), Some(speed));
} else if !line.trim().is_empty() {
last = line;
}
}
}
last
});
let st = child.wait().await?;
let last = task.await.unwrap_or_default();
if !st.success() {
return Err(anyhow!("aria2c falhou: {}", last));
}
// aria2 decide o nome pelo Content-Disposition/URL; pega o arquivo mais novo da pasta
let path = if !opts.file_name.trim().is_empty() {
PathBuf::from(&opts.dest_dir).join(opts.file_name.trim())
} else {
std::fs::read_dir(&opts.dest_dir)?
.flatten()
.filter(|e| e.path().is_file() && !e.path().to_string_lossy().ends_with(".aria2"))
.max_by_key(|e| e.metadata().and_then(|m| m.modified()).ok())
.map(|e| e.path())
.ok_or_else(|| anyhow!("download terminou mas nao achei o arquivo"))?
};
let bytes = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0);
super::report(&progress, &id, "done", 100, Some(100), None);
Ok(Aria2Result {
path: path.to_string_lossy().to_string(),
bytes,
})View on GitHub (pinned to 8600b91f42)