{"record":{"id":"34f32ba071576f34","repo":"cjpais/Handy","slug":"complete-model-file-not-found-in-hf-cache-or-model","errorCode":null,"errorMessage":"Complete model file not found in HF cache or models dir: {}","messagePattern":"Complete model file not found in HF cache or models dir: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/src/managers/model.rs","lineNumber":2598,"sourceCode":"            if let Some(path) = hf_cached_path(repo_id, revision, &model_info.filename) {\n                return Ok(path);\n            }\n            // Mirror-fallback download or manual drop-in in the models dir.\n            // The complete file only ever appears after verification, so a\n            // stale `.partial` alongside it is leftover noise, not a veto —\n            // clear it rather than declaring the model missing.\n            let local_path = self.models_dir.join(&model_info.filename);\n            if local_path.exists() {\n                let partial_path = self\n                    .models_dir\n                    .join(format!(\"{}.partial\", &model_info.filename));\n                if partial_path.exists() {\n                    let _ = fs::remove_file(&partial_path);\n                }\n                return Ok(local_path);\n            }\n            self.mark_model_unavailable(model_id);\n            return Err(anyhow::anyhow!(\n                \"Complete model file not found in HF cache or models dir: {}\",\n                model_id\n            ));\n        }\n\n        let model_path = self.models_dir.join(&model_info.filename);\n        let partial_path = self\n            .models_dir\n            .join(format!(\"{}.partial\", &model_info.filename));\n\n        if model_info.is_directory {\n            if !model_path.exists() || !model_path.is_dir() {\n                self.mark_model_unavailable(model_id);\n                return Err(anyhow::anyhow!(\n                    \"Complete model directory not found: {}\",\n                    model_id\n                ));\n            }","sourceCodeStart":2580,"sourceCodeEnd":2616,"githubUrl":"https://github.com/cjpais/Handy/blob/ba10ce1943ef34e93c09494027fc0b9ced2e8a44/src-tauri/src/managers/model.rs#L2580-L2616","documentation":"An HuggingFace-sourced model is flagged downloaded, but neither the HF cache snapshot path (hf_cached_path) nor the file in models_dir exists. The manager treats the HF cache as externally owned: if the user wipes it (or the snapshot pointer is broken) while is_downloaded stays true, the state lies and this error exposes it. Note the code already tolerates a stale .partial next to an existing local file and cleans it up — this error means there is genuinely no complete file anywhere.","triggerScenarios":"User deleted ~/.cache/huggingface (or ran huggingface-cli delete-cache) while the app was closed; alternate-quant blob removed but snapshot pointer remained; models dir moved/restored from backup without the model; app data copied between machines without the HF cache.","commonSituations":"Disk-space cleanup tools wiping HF caches; migrating installs; file sync conflicts removing large blobs.","solutions":["Delete and re-download the model — this resets is_downloaded and restores the cache entry","Restore the HF cache blob/snapshot from backup if you have one","Manually place the model file in the models dir under model_info.filename (manual drop-ins are supported)","As a maintainer: on this error, auto-clear is_downloaded so the UI immediately shows the re-download action"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// verify the file actually exists before trusting is_downloaded\nlet path = hf_cached_path(&repo_id, &revision, &filename)\n    .or_else(|| {\n        let p = self.models_dir.join(&filename);\n        p.exists().then_some(p)\n    })\n    .ok_or_else(|| anyhow::anyhow!(\"HF model {model_id} missing from disk — re-download\"))?\n// (get_model_path already implements exactly this check — call it, don't cache stale paths)\nlet _ = std::fs::metadata(&path)?; // resolve symlinked blobs eagerly","typeGuard":null,"tryCatchPattern":"match manager.get_model_path(id) {\n    Err(e) if e.to_string().contains(\"not found in HF cache\") => {\n        // re-download resets the stale is_downloaded flag\n        manager.delete_model(id)?;\n        manager.download_model(id).await?;\n    }\n    other => other?,\n}","preventionTips":["Never cache resolved model paths across sessions — re-resolve via get_model_path each time","If you wipe the HF cache externally, delete the model in-app first so flags stay honest","Clear is_downloaded automatically when this error is hit, so the UI offers re-download immediately"],"tags":["rust","huggingface","cache","missing-file","state-drift"],"backgroundTag":"missing-file-on-disk","analyzedSha":"ba10ce1943ef34e93c09494027fc0b9ced2e8a44","analyzedAt":"2026-09-17T15:09:05.215Z","contentChangedAt":"2026-09-17T15:09:05.215Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}