{"record":{"id":"a730a64c9445bde0","repo":"Zackriya-Solutions/meetily","slug":"failed-to-delete-file","errorCode":null,"errorMessage":"Failed to delete file '{}': {}","messagePattern":"Failed to delete file '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/whisper_engine/whisper_engine.rs","lineNumber":853,"sourceCode":"        // Get model info to find the file path\n        let model_info = {\n            let models = self.available_models.read().await;\n            models.get(model_name).cloned()\n        };\n\n        let model_info = model_info.ok_or_else(|| anyhow!(\"Model '{}' not found\", model_name))?;\n\n        // Check if model is corrupted before allowing deletion\n        log::info!(\"Model '{}' has status: {:?}\", model_name, model_info.status);\n        match &model_info.status {\n            ModelStatus::Corrupted { file_size, expected_min_size } => {\n                log::info!(\"Deleting corrupted model '{}' (file size: {} bytes, expected min: {} bytes)\",\n                          model_name, file_size, expected_min_size);\n\n                // Delete the file\n                if model_info.path.exists() {\n                    fs::remove_file(&model_info.path).await\n                        .map_err(|e| anyhow!(\"Failed to delete file '{}': {}\", model_info.path.display(), e))?;\n                    log::info!(\"Successfully deleted corrupted file: {}\", model_info.path.display());\n                } else {\n                    log::warn!(\"File '{}' does not exist, nothing to delete\", model_info.path.display());\n                }\n\n                // Update model status to Missing\n                {\n                    let mut models = self.available_models.write().await;\n                    if let Some(model) = models.get_mut(model_name) {\n                        model.status = ModelStatus::Missing;\n                    }\n                }\n\n                Ok(format!(\"Successfully deleted corrupted model '{}'\", model_name))\n            }\n            ModelStatus::Available => {\n                // Allow deletion of available models for testing/cleanup\n                log::info!(\"Deleting available model '{}' (for cleanup)\", model_name);","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/whisper_engine/whisper_engine.rs#L835-L871","documentation":"In delete_model's Corrupted branch, tokio fs::remove_file on the model path failed and the OS error is appended. The path in the message plus the errno identify the blocker: PermissionDenied (locked or read-only), NotFound (already gone), or IsADirectory. The status is not reset to Missing when this fires.","triggerScenarios":"Windows file lock: another process (antivirus, a still-loaded whisper context, second app instance) holds an open handle on the ggml file; read-only file permissions; models dir on a volume unmounted mid-operation.","commonSituations":"Windows delete-after-load flows where the model context was never unloaded; corporate machines with AV scanning new .bin files; models stored on external/network drives.","solutions":["Call unload_model before delete_model so no open file handle remains","Close other app instances and wait a few seconds for antivirus scans to release the file, then retry","Fix permissions on the models directory (remove read-only flag, verify ownership) and retry","As a last resort, delete ggml-<name>.bin manually and rescan models"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Unload first so no open handle remains, then delete\nawait invoke('unload_whisper_model');\nawait invoke('delete_model', { modelName });","typeGuard":null,"tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try {\n    await invoke('delete_model', { modelName });\n    break;\n  } catch (e) {\n    if (String(e).includes('Failed to delete file') && attempt < 3) {\n      await sleep(1000 * attempt); // AV/lock usually clears; retry\n    } else { throw e; }\n  }\n}","preventionTips":["Call unload_model before deleting any model file, especially on Windows","Run a single app instance; cloud-sync and AV clients are common file-lock sources in the models dir","Show the OS error string to the user — PermissionDenied vs NotFound need different actions"],"tags":["whisper","filesystem","permissions","windows","rust"],"backgroundTag":"file-delete-permission-denied","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}