tonhowtf/omniget · info
Download cancelled
Error message
Download cancelled
What it means
download_attachment checks a cooperative cancellation token before issuing the HTTP GET for an attachment. If cancel_token.is_cancelled() is true, it aborts with "Download cancelled". This is a normal, expected control-flow error used to stop in-flight or queued attachment downloads.
Solutions
- Treat this error as an expected outcome: catch it and update the UI to 'cancelled' rather than showing it as a failure.
- If downloads are being cancelled unintentionally, audit where cancel_token.cancel() is called (timeout handlers, task aborts, parent cancellation).
- Re-issue the download with a fresh (non-cancelled) token if the cancellation was spurious.
- Filter this specific message out of generic error reporting paths so it does not surface as a crash log.
Example fix
// before
match download_attachment(&client, &url, &dest, &token).await {
Err(e) => log::error!("attachment failed: {}", e),
Ok(n) => log::info!("downloaded {} bytes", n),
}
// after
match download_attachment(&client, &url, &dest, &token).await {
Err(e) if e.to_string().contains("Download cancelled") => log::info!("attachment download cancelled by user"),
Err(e) => log::error!("attachment failed: {}", e),
Ok(n) => log::info!("downloaded {} bytes", n),
} Defensive patterns
Strategy: try-catch
Validate before calling
// Check the token before starting so work is skipped cheaply
if cancel_token.is_cancelled() {
return Ok(0); // or skip the attachment entirely
} Try / catch
match download_attachment(&client, &url, &dest, &token).await {
Err(e) if e.to_string() == "Download cancelled" => {
log::info!("skipped (cancelled): {}", url);
Ok(0)
}
other => other.map(|_| ()),
} Prevention
- Treat cancellation as a normal outcome, not a failure
- Model cancellation with a typed enum instead of string matching where possible
- Cancel tokens deterministically and document where cancel() is called
- Update download UI state to 'cancelled' on this error
When it happens
Trigger: The user (or application logic) cancels a course/attachment download — cancel_token.cancel() is called on the shared CancellationToken while download_attachment is running or about to start; the next is_cancelled() check at course_utils.rs:74 returns true before the request is sent.
Common situations: User pressing a cancel/stop button in the download UI; app shutdown while downloads are queued; a parent download manager cancelling all per-attachment tokens when the overall task is aborted.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/36a22ac4865c381d.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/course_utils.rs:74
.and_then(|e| e.split('?').next())
.filter(|e| e.len() <= 5)
.unwrap_or("bin");
format!("attachment.{}", ext)
} else {
sanitized
};
let path = format!("{}/{}", dir, filename);
if Path::new(&path).exists() {
let meta = std::fs::metadata(&path);
if meta.map(|m| m.len() > 0).unwrap_or(false) {
return Ok(0);
}
}
if cancel_token.is_cancelled() {
return Err(anyhow!("Download cancelled"));
}
let resp = client
.get(url)
.send()
.await
.map_err(|e| anyhow!("Failed to download attachment: {}", e))?;
if !resp.status().is_success() {
return Err(anyhow!(
"Attachment download failed: HTTP {}",
resp.status()
));
}
let bytes = resp.bytes().await?;
let size = bytes.len() as u64;
View on GitHub (pinned to 8600b91f42)