{"record":{"id":"33182402c4f1cc78","repo":"cjpais/Handy","slug":"failed-to-verify-download-for-model-please","errorCode":null,"errorMessage":"Failed to verify download for model {}: {}. Please retry.","messagePattern":"Failed to verify download for model (.+?): (.+?)\\. Please retry\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/model/download.rs","lineNumber":78,"sourceCode":"        match Self::compute_sha256(path) {\n            Ok(actual) if actual == expected => {\n                info!(\"SHA256 verified for model {}\", model_id);\n                Ok(())\n            }\n            Ok(actual) => {\n                warn!(\n                    \"SHA256 mismatch for model {}: expected {}, got {}\",\n                    model_id, expected, actual\n                );\n                let _ = fs::remove_file(path);\n                Err(anyhow::anyhow!(\n                    \"Download verification failed for model {}: file is corrupt. Please retry.\",\n                    model_id\n                ))\n            }\n            Err(e) => {\n                let _ = fs::remove_file(path);\n                Err(anyhow::anyhow!(\n                    \"Failed to verify download for model {}: {}. Please retry.\",\n                    model_id,\n                    e\n                ))\n            }\n        }\n    }\n\n    /// Computes the SHA256 hex digest of a file, reading in 64KB chunks to handle large models.\n    fn compute_sha256(path: &Path) -> Result<String> {\n        let mut file = File::open(path)?;\n        let mut hasher = Sha256::new();\n        let mut buffer = [0u8; 65536];\n        loop {\n            let n = file.read(&mut buffer)?;\n            if n == 0 {\n                break;\n            }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/cjpais/Handy/blob/c89b7bf38974ad317177389f5bfe28236f0d64e3/src-tauri/src/managers/model/download.rs#L60-L96","documentation":"Raised when computing the SHA256 of a downloaded model fails outright (compute_sha256 returns Err), as opposed to computing successfully but mismatching. The cause is an I/O error while reading the file — typically the file vanished, is locked, or the disk failed mid-read. Like the mismatch case, the file is deleted before the error is returned.","triggerScenarios":"File::open(path) or a chunk read inside compute_sha256 fails: the partial file was deleted by another process, the disk filled or disconnected, or filesystem permissions changed between download completion and verification.","commonSituations":"External cleanup tools or a second app instance touching the models directory; disk-full on the same volume that just hosted a multi-GB download; network drives/cloud-sync folders (Dropbox/OneDrive) evicting or locking the file mid-hash; failing sectors on large files.","solutions":["Retry the download — the code already removed the unreadable file.","Check free disk space; large models need headroom for both the file and temp writes.","Move the models directory off cloud-synced/network storage — sync agents lock or swap files during hashing.","If it persists, check filesystem permissions and disk health (dmesg/Event Viewer for I/O errors)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match manager.download_model(model_id, None).await {\n    Ok(_) => Ok(()),\n    Err(e) if e.to_string().contains(\"Failed to verify download\") => {\n        // I/O-level verify failure; file removed, safe to retry once\n        tokio::time::sleep(std::time::Duration::from_secs(2)).await;\n        manager.download_model(model_id, None).await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Keep the models directory on local, non-synced storage.","Ensure free disk space of at least the model size before downloading.","Only one process at a time should touch the models directory (single-instance app).","Monitor disk health if hash I/O errors repeat."],"tags":["download","sha256","io","verification","disk"],"backgroundTag":"checksum-verification-failed","analyzedSha":"c89b7bf38974ad317177389f5bfe28236f0d64e3","analyzedAt":"2026-08-17T10:29:55.597Z","contentChangedAt":"2026-08-17T10:29:55.597Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}