{"record":{"id":"426c5175a42c323c","repo":"Zackriya-Solutions/meetily","slug":"download-cancelled-by-user-426c51","errorCode":null,"errorMessage":"Download cancelled by user","messagePattern":"Download cancelled by user","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"info","filePath":"frontend/src-tauri/src/whisper_engine/whisper_engine.rs","lineNumber":1017,"sourceCode":"        let mut downloaded = 0u64;\n        let mut last_progress_report = 0u8;\n        let mut last_report_time = std::time::Instant::now();\n\n        // Emit initial 0% progress immediately\n        if let Some(ref callback) = progress_callback {\n            callback(0);\n        }\n\n        while let Some(chunk_result) = stream.next().await {\n            // Check for cancellation before processing chunk\n            {\n                let cancel_flag = self.cancel_download_flag.read().await;\n                if cancel_flag.as_ref() == Some(&model_name.to_string()) {\n                    log::info!(\"Download cancelled for {}\", model_name);\n                    // Remove from active downloads on cancellation\n                    let mut active = self.active_downloads.write().await;\n                    active.remove(model_name);\n                    return Err(anyhow!(\"Download cancelled by user\"));\n                }\n            }\n\n            let chunk = chunk_result\n                .map_err(|e| anyhow!(\"Failed to read chunk: {}\", e))?;\n\n            file.write_all(&chunk).await\n                .map_err(|e| anyhow!(\"Failed to write chunk to file: {}\", e))?;\n\n            downloaded += chunk.len() as u64;\n\n            // Calculate progress\n            let progress = if total_size > 0 {\n                ((downloaded as f64 / total_size as f64) * 100.0) as u8\n            } else {\n                0\n            };\n","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/whisper_engine/whisper_engine.rs#L999-L1035","documentation":"Inside the streaming loop, each iteration checks cancel_download_flag; when it equals this model's name the loop exits, the model is removed from active_downloads, and this error propagates. It is intentional control flow for the Cancel button, not a failure — but it travels the Err channel, so callers must distinguish it from real failures.","triggerScenarios":"User clicks Cancel while the progress callback streams updates; a UI flow cancels a download to switch to a different model size mid-transfer.","commonSituations":"Normal UX cancellation; automated flows cancelling when a faster/quantized variant is preferred; test harnesses cancelling deliberately.","solutions":["Treat this message as expected: catch it and show an informational 'Download cancelled' state, not an error","To restart, call download_model again — note there is no byte-range resume, it restarts from 0","Reset the model's progress state in the UI after cancellation so it shows as not-downloaded"],"exampleFix":"// before\ntry { await invoke('download_model', { modelName }); }\ncatch (e) { showError(e); } // shows 'cancelled' as a scary error\n\n// after\ntry { await invoke('download_model', { modelName }); }\ncatch (e: any) {\n  if (String(e).includes('cancelled by user')) setCancelledState();\n  else showError(e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await invoke('download_model', { modelName });\n} catch (e) {\n  const msg = String(e);\n  if (msg.includes('Download cancelled by user')) {\n    setModelState(modelName, 'not-downloaded'); // expected flow, no error UI\n  } else {\n    showError(msg);\n  }\n}","preventionTips":["Classify 'cancelled by user' as an info outcome in error handling from day one","Reset progress UI and model status when the cancel path fires","Remember re-download restarts from byte 0; keep the partial file's fate in mind for disk cleanup"],"tags":["whisper","download","cancellation","rust","ux"],"backgroundTag":"operation-cancelled-by-user","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}