{"record":{"id":"c34609c3099cb3ad","repo":"Zackriya-Solutions/meetily","slug":"failed-to-flush-file-c34609","errorCode":null,"errorMessage":"Failed to flush file: {}","messagePattern":"Failed to flush file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/whisper_engine/whisper_engine.rs","lineNumber":1077,"sourceCode":"            }\n        }\n\n        log::info!(\"Streaming download completed: {} bytes\", downloaded);\n        \n        // Ensure 100% progress is always reported\n        {\n            let mut models = self.available_models.write().await;\n            if let Some(model_info) = models.get_mut(model_name) {\n                model_info.status = ModelStatus::Downloading { progress: 100 };\n            }\n        }\n        \n        if let Some(ref callback) = progress_callback {\n            callback(100);\n        }\n        \n        file.flush().await\n            .map_err(|e| anyhow!(\"Failed to flush file: {}\", e))?;\n        \n        log::info!(\"Download completed for model: {}\", model_name);\n        \n        // Update model status to available\n        {\n            let mut models = self.available_models.write().await;\n            if let Some(model_info) = models.get_mut(model_name) {\n                model_info.status = ModelStatus::Available;\n                model_info.path = file_path.clone();\n            }\n        }\n\n        // Remove from active downloads on completion\n        {\n            let mut active = self.active_downloads.write().await;\n            active.remove(model_name);\n        }\n","sourceCodeStart":1059,"sourceCodeEnd":1095,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/whisper_engine/whisper_engine.rs#L1059-L1095","documentation":"After the stream completes, the final file.flush() failed; the OS error is appended. This usually means buffered data could not be committed to disk — ENOSPC at close time (space calculations during streaming were optimistic because writes were buffered) or an I/O error from a failing device. The file can be incomplete even though every chunk write 'succeeded'.","triggerScenarios":"Disk fills exactly as the last buffers flush at close; USB/external drive errors or forced unmount at the end of a large write; filesystem corruption.","commonSituations":"Free space just barely above the model size; flaky external storage; large-v3 downloads on nearly-full disks.","solutions":["Free disk space beyond the model size (leave a healthy margin for OS buffers) and re-download","Run a disk health check if flush errors repeat on the same device","Verify the resulting file size matches the expected size before loading; a short file will otherwise surface later as Corrupted"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: after download, verify size before trusting the file\nlet meta = fs::metadata(&file_path).await?;\nif meta.len() + 50 * 1024 * 1024 > fs2::available_space(&self.models_dir)? {\n    return Err(anyhow!(\"Margin too thin for flush; free space\"));\n}","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('download_model', { modelName });\n} catch (e) {\n  if (String(e).includes('Failed to flush file')) {\n    await cleanupPartial(modelName);\n    await invoke('download_model', { modelName }); // retry after freeing space\n  } else { throw e; }\n}","preventionTips":["Require free space of model size plus a buffer (OS write-behind makes streaming counts optimistic)","Treat flush failures at end-of-download as disk-health warnings if they recur","Validate the final file size against the expected size before marking the model Available"],"tags":["filesystem","disk-space","download","io","rust"],"backgroundTag":"out-of-disk-space","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}