{"record":{"id":"5bfe7f71156942d5","repo":"Zackriya-Solutions/meetily","slug":"failed-to-delete-directory","errorCode":null,"errorMessage":"Failed to delete directory '{}': {}","messagePattern":"Failed to delete directory '(.+?)': (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs","lineNumber":502,"sourceCode":"        log::info!(\"Attempting to delete Parakeet model: {}\", model_name);\n\n        // Get model info to find the directory 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!(\"Parakeet model '{}' not found\", model_name))?;\n\n        log::info!(\"Parakeet model '{}' has status: {:?}\", model_name, model_info.status);\n\n        // Allow deletion of corrupted or available models\n        match &model_info.status {\n            ModelStatus::Corrupted { .. } | ModelStatus::Available => {\n                // Delete the entire model directory\n                if model_info.path.exists() {\n                    fs::remove_dir_all(&model_info.path).await\n                        .map_err(|e| anyhow!(\"Failed to delete directory '{}': {}\", model_info.path.display(), e))?;\n                    log::info!(\"Successfully deleted Parakeet model directory: {}\", model_info.path.display());\n                } else {\n                    log::warn!(\"Directory '{}' 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 Parakeet model '{}'\", model_name))\n            }\n            _ => {\n                Err(anyhow!(\n                    \"Can only delete corrupted or available Parakeet models. Model '{}' has status: {:?}\",","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs#L484-L520","documentation":"Returned by delete_model when tokio fs::remove_dir_all fails on the model directory. The directory is models_dir/<name> and contains multi-hundred-MB ONNX files; typical causes are a file inside being locked (ONNX Runtime may still hold the loaded model's files, especially on Windows), missing permissions, or the directory disappearing/vanishing concurrently.","triggerScenarios":"Calling delete_model while the same model is still loaded in current_model (session may memory-map or keep handles open); deleting on Windows while an antivirus scans the freshly written .onnx files; models directory made read-only or owned by another user; a race where another delete call already removed the tree.","commonSituations":"UI offers 'delete and re-download' without unloading first; corporate endpoint protection locks large downloads; app runs from a different user account than the one that created the models dir.","solutions":["Call engine.unload_model() (parakeet_load_model of another model, or app restart) before deleting the model's files","Retry the delete after a short delay - AV/file-handle locks are usually transient","Check permissions/ownership of the models dir and fix with chmod/chown or Explorer properties","If it still fails, open the folder via open_parakeet_models_folder and delete the model directory by hand"],"exampleFix":"// before\nengine.delete_model(name).await?;\n\n// after - unload before deleting so no session holds the files\nif engine.get_current_model().await.as_deref() == Some(name.as_str()) {\n    engine.unload_model().await;\n}\nengine.delete_model(name).await?;","handlingStrategy":"retry","validationCode":"// Unload first if the model being deleted is the active one\nif engine.get_current_model().await.as_deref() == Some(name.as_str()) {\n    engine.unload_model().await;\n}\n// Also confirm the directory exists and is writable\nlet dir = engine.get_models_directory().await.join(name);\nif dir.exists() && dir.metadata().map(|m| m.permissions().readonly()).unwrap_or(false) {\n    anyhow::bail!(\"model directory is read-only: {}\", dir.display());\n}","typeGuard":null,"tryCatchPattern":"// Retry with backoff - AV/file locks are usually transient\nlet mut attempt = 0;\nloop {\n    match engine.delete_model(name).await {\n        Ok(msg) => break msg,\n        Err(e) if e.to_string().contains(\"Failed to delete directory\") && attempt < 3 => {\n            attempt += 1;\n            tokio::time::sleep(std::time::Duration::from_secs(2 * attempt as u64)).await;\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Unload the model before deleting its files - loaded ONNX sessions can hold handles (notably Windows)","Exclude the models directory from real-time AV scanning and cloud sync","After delete, refresh the model list so the UI reflects Missing status"],"tags":["parakeet","filesystem","file-locked","windows","model-management"],"backgroundTag":"file-locked","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}