Zackriya-Solutions/meetily · error · anyhow::Error

Failed to delete directory '{}': {}

Error message

Failed to delete directory '{}': {}

What it means

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.

Source

Thrown at frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs:502

        log::info!("Attempting to delete Parakeet model: {}", model_name);

        // Get model info to find the directory path
        let model_info = {
            let models = self.available_models.read().await;
            models.get(model_name).cloned()
        };

        let model_info = model_info.ok_or_else(|| anyhow!("Parakeet model '{}' not found", model_name))?;

        log::info!("Parakeet model '{}' has status: {:?}", model_name, model_info.status);

        // Allow deletion of corrupted or available models
        match &model_info.status {
            ModelStatus::Corrupted { .. } | ModelStatus::Available => {
                // Delete the entire model directory
                if model_info.path.exists() {
                    fs::remove_dir_all(&model_info.path).await
                        .map_err(|e| anyhow!("Failed to delete directory '{}': {}", model_info.path.display(), e))?;
                    log::info!("Successfully deleted Parakeet model directory: {}", model_info.path.display());
                } else {
                    log::warn!("Directory '{}' does not exist, nothing to delete", model_info.path.display());
                }

                // Update model status to Missing
                {
                    let mut models = self.available_models.write().await;
                    if let Some(model) = models.get_mut(model_name) {
                        model.status = ModelStatus::Missing;
                    }
                }

                Ok(format!("Successfully deleted Parakeet model '{}'", model_name))
            }
            _ => {
                Err(anyhow!(
                    "Can only delete corrupted or available Parakeet models. Model '{}' has status: {:?}",

View on GitHub (pinned to 0281737d87)

Solutions

  1. Call engine.unload_model() (parakeet_load_model of another model, or app restart) before deleting the model's files
  2. Retry the delete after a short delay - AV/file-handle locks are usually transient
  3. Check permissions/ownership of the models dir and fix with chmod/chown or Explorer properties
  4. If it still fails, open the folder via open_parakeet_models_folder and delete the model directory by hand

Example fix

// before
engine.delete_model(name).await?;

// after - unload before deleting so no session holds the files
if engine.get_current_model().await.as_deref() == Some(name.as_str()) {
    engine.unload_model().await;
}
engine.delete_model(name).await?;
Defensive patterns

Strategy: retry

Validate before calling

// Unload first if the model being deleted is the active one
if engine.get_current_model().await.as_deref() == Some(name.as_str()) {
    engine.unload_model().await;
}
// Also confirm the directory exists and is writable
let dir = engine.get_models_directory().await.join(name);
if dir.exists() && dir.metadata().map(|m| m.permissions().readonly()).unwrap_or(false) {
    anyhow::bail!("model directory is read-only: {}", dir.display());
}

Try / catch

// Retry with backoff - AV/file locks are usually transient
let mut attempt = 0;
loop {
    match engine.delete_model(name).await {
        Ok(msg) => break msg,
        Err(e) if e.to_string().contains("Failed to delete directory") && attempt < 3 => {
            attempt += 1;
            tokio::time::sleep(std::time::Duration::from_secs(2 * attempt as u64)).await;
        }
        Err(e) => return Err(e),
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/5bfe7f71156942d5. Report an issue: GitHub.