tonhowtf/omniget · error
download terminou mas nao achei o arquivo
Error message
download terminou mas nao achei o arquivo
What it means
When opts.file_name is empty, download() infers the output file by listing dest_dir and picking the newest non-`.aria2` regular file by modification time. If the directory has no such file after aria2c exits successfully, it fails with this message — the post-download file discovery found nothing.
Solutions
- Always set opts.file_name explicitly so the code does not have to guess by mtime.
- Verify dest_dir is the exact same absolute directory aria2c writes to.
- Check dest_dir contents for files stuck with a .aria2 control suffix (incomplete download).
- Re-run and watch aria2c's stdout for the actual save path.
Example fix
// before
let path = if !opts.file_name.trim().is_empty() { ... } else { ...ok_or_else(...)? };
// after
let file_name = if opts.file_name.trim().is_empty() {
// derive from URL as a fallback before scanning the dir
url_file_name(&opts.url).ok_or_else(|| anyhow!("informe file_name: nao foi possivel deduzir o nome do arquivo"))?
} else { opts.file_name.trim().to_string() };
let path = PathBuf::from(&opts.dest_dir).join(file_name); Defensive patterns
Strategy: validation
Validate before calling
// antes de chamar: assert!(!opts.file_name.trim().is_empty(), "informe file_name explicitamente"); assert!(Path::new(&opts.dest_dir).is_dir(), "dest_dir nao existe");
Try / catch
match aria2::download(opts).await {
Err(e) if e.to_string().contains("nao achei o arquivo") => {
eprintln!("defina opts.file_name para nao depender da heuristica de mtime");
}
other => other?,
} Prevention
- Always populate opts.file_name — never rely on the newest-file heuristic.
- Use absolute paths for dest_dir so aria2c and the scanner agree on the directory.
- Ensure only one download runs per dest_dir to avoid mtime ambiguity.
When it happens
Trigger: aria2c exited 0 but wrote nothing into dest_dir (e.g. empty/redirect-only response), or dest_dir path differs from aria2c's actual save directory (relative vs absolute path, --dir mismatch), or all files still have .aria2 suffixes.
Common situations: URL that resolves to an empty 200 response; passing a dest_dir that doesn't match the cwd-dependent relative path aria2c used; concurrent downloads in the same dir cleaning files; aria2 saving under a different --dir option.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- aria2c falhou
- Track sem metadata pra resolver no YouTube
- download falhou: HTTP
- download de falhou: HTTP
- HTTP
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/c691107380990182.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/aria2.rs:139
}
}
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,
})
}
#[cfg(test)]
mod tests {
#[test]
fn parses_line() {
let (p, s) =
super::parse_progress("[#2089b0 12MiB/100MiB(12%) CN:16 DL:5.0MiB ETA:10s]").unwrap();
assert_eq!(p, 12);
assert_eq!(s, "5.0MiB");
}View on GitHub (pinned to 8600b91f42)