{"record":{"id":"67b8781e5b839818","repo":"Zackriya-Solutions/meetily","slug":"failed-to-read-after-download","errorCode":null,"errorMessage":"Failed to read {} after download: {}","messagePattern":"Failed to read (.+?) after download: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs","lineNumber":1102,"sourceCode":"                    self.set_downloading_status(model_name, progress.percent).await;\n                    last_percent = progress.percent;\n                    last_report = Instant::now();\n                    bytes_since_report = 0;\n                }\n            }\n\n            writer\n                .flush()\n                .await\n                .map_err(|error| anyhow!(\"Failed to flush {}: {}\", artifact.filename, error))?;\n            drop(writer);\n\n            if active_download.cancellation.is_cancelled() {\n                return Err(DownloadCancelled.into());\n            }\n            let stored_bytes = fs::metadata(&file_path)\n                .await\n                .map_err(|error| anyhow!(\"Failed to read {} after download: {}\", artifact.filename, error))?\n                .len();\n            if stored_bytes != artifact.exact_bytes {\n                return Err(anyhow!(\n                    \"{} stored {} bytes, expected exactly {} bytes\",\n                    artifact.filename,\n                    stored_bytes,\n                    artifact.exact_bytes\n                ));\n            }\n        }\n\n        if confirmed_bytes != total_bytes {\n            return Err(anyhow!(\n                \"Download confirmed {} bytes, expected {} bytes\",\n                confirmed_bytes,\n                total_bytes\n            ));\n        }","sourceCodeStart":1084,"sourceCodeEnd":1120,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/a2cb62e827da7ef59f65064c97233efb2313878e/frontend/src-tauri/src/parakeet_engine/parakeet_engine.rs#L1084-L1120","documentation":"After a model artifact download completes, the engine calls fs::metadata(&file_path) to verify the stored file size. If the metadata read fails (the file is missing or unreadable), it wraps that OS error with this message. It is a post-download integrity check: the engine expected a fully written artifact on disk but could not even stat it.","triggerScenarios":"In the Parakeet download flow, after the download future resolves, fs::metadata(&file_path).await returns Err — typically because the file was deleted between download completion and verification, the path is wrong, a concurrent cancel/cleanup removed it, or filesystem permission issues prevent stat on the artifact.","commonSituations":"Antivirus/OS quarantining or deleting a freshly downloaded model file; the download worker's cleanup racing with verification after a cancellation; a corrupted partial file removed by a prior crashed run leaving a stale path; disk that was remounted or permissions changed mid-download.","solutions":["Re-trigger the download to regenerate the artifact cleanly (delete the partial/stale file first).","Check that the models directory exists and the process has read permission on the artifact path (ls -l / stat the file).","Rule out antivirus or cleanup software deleting files in the model storage directory; add an exclusion for it.","Ensure no concurrent cancel_download call races the download completion; wait for the download to fully finish before cancelling."],"exampleFix":"// before\nlet stored_bytes = fs::metadata(&file_path)\n    .await\n    .map_err(|error| anyhow!(\"Failed to read {} after download: {}\", artifact.filename, error))?;\n// after (retry metadata read once before failing)\nlet stored_bytes = match fs::metadata(&file_path).await {\n    Ok(m) => m.len(),\n    Err(_) => {\n        tokio::time::sleep(std::time::Duration::from_millis(100)).await;\n        fs::metadata(&file_path)\n            .await\n            .map_err(|error| anyhow!(\"Failed to read {} after download: {}\", artifact.filename, error))?\n            .len()\n    }\n};","handlingStrategy":"try-catch","validationCode":"// Rust: pre-check artifact path exists before/after download\nif !tokio::fs::try_exists(&file_path).await.unwrap_or(false) {\n    eprintln!(\"artifact missing, will need re-download: {:?}\", file_path);\n}","typeGuard":"// Rust: narrow the metadata result before using len()\nfn stored_len(meta: io::Result<std::fs::Metadata>) -> Option<u64> {\n    meta.ok().map(|m| m.len())\n}","tryCatchPattern":"// Rust\nmatch fs::metadata(&file_path).await {\n    Ok(meta) => verify_size(meta.len()),\n    Err(e) => {\n        // treat as corrupt/missing: clean up and retry download once\n        let _ = fs::remove_file(&file_path).await;\n        retry_download(artifact).await\n    }\n}","preventionTips":["Add an exclusion for the models directory in antivirus/endpoint protection software.","Avoid cancelling downloads concurrently with completion verification.","Clean stale partial files before starting a new download.","Monitor free disk space and mount state of the models volume."],"tags":["filesystem","download","rust","model-management"],"backgroundTag":"file-not-found","analyzedSha":"a2cb62e827da7ef59f65064c97233efb2313878e","analyzedAt":"2026-09-12T11:12:14.152Z","contentChangedAt":"2026-09-12T11:12:14.152Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}