tonhowtf/omniget · error · anyhow
caminho de modelo sem pasta
Error message
caminho de modelo sem pasta
What it means
`ensure_model` derives the download directory as `dest.parent()`; since `model_path` always joins a filename onto models_dir, a None parent is an internal invariant violation ('caminho de modelo sem pasta'). In practice this is defensive code and effectively unreachable unless model_path's construction changes.
Solutions
- If you hit it, inspect `models_dir()`/`model_path()` in core/tools/onnx.rs — the path construction lost its directory component; restore the `tools_dir().join("models").join("onnx")` structure.
- As a caller, nothing you can pass to ensure_model causes this; fix the library code instead.
- Add a unit test asserting `model_path("u2netp")` has a parent to catch regressions.
Example fix
// before
pub fn models_dir() -> Option<PathBuf> { super::tools_dir().map(|d| d.join("onnx")) }
// after
pub fn models_dir() -> Option<PathBuf> { super::tools_dir().map(|d| d.join("models").join("onnx")) } Defensive patterns
Strategy: try-catch
Validate before calling
// callers cannot prevent this; it indicates a library bug in models_dir()/model_path()
// guard: ensure the models dir resolves before calling
if onnx::status(None).models_dir.is_none() { return Err(anyhow!("models_dir nao resolve")); } Try / catch
match onnx::ensure_model(id, &progress).await {
Err(e) if e.to_string().contains("sem pasta") => {
anyhow::bail!("bug interno no caminho de modelos; reporte com o log");
}
other => other,
} Prevention
- Keep a unit test asserting model_path(id).unwrap().parent().is_some() for every catalog id.
- Avoid refactors that make models_dir() return a bare filename or empty path.
- Treat this error as a bug report trigger, not a user-facing condition.
When it happens
Trigger: Theoretically any `ensure_model` call would trigger this only if `model_path(id)` ever returned a path without a parent component (e.g. a bare relative filename after a refactor of model_path/models_dir).
Common situations: Only after code changes: someone edits `models_dir()` or `model_path()` to return a root-level or relative path; custom forks that alter the models directory layout.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- gallery-dl binary not found after download
- variante sumiu do catálogo
- não achei o diretório de dados do app
- binario sumiu apos instalar
- whisper-cli sumiu depois de mover a pasta
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/14c2427a8b436cac.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/onnx.rs:201
if n == 0 {
break;
}
hasher.update(&buf[..n]);
}
Ok(hex::encode(hasher.finalize()))
}
/// Garante o modelo no disco. Se já está lá com o tamanho certo, não baixa de
/// novo. O sha256 é conferido no arquivo recém-baixado, antes de virar oficial.
pub async fn ensure_model(id: &str, progress: &ProgressFn) -> anyhow::Result<PathBuf> {
let spec = find(id).ok_or_else(|| anyhow!("modelo desconhecido: {id}"))?;
let dest = model_path(id).ok_or_else(|| anyhow!("não achei o diretório de dados do app"))?;
if is_downloaded(id) {
return Ok(dest);
}
let dir = dest
.parent()
.ok_or_else(|| anyhow!("caminho de modelo sem pasta"))?
.to_path_buf();
std::fs::create_dir_all(&dir).with_context(|| format!("criando {}", dir.display()))?;
let tmp = dir.join(format!(".{id}.onnx.download"));
let client = super::client()?;
let pid = format!("onnx-model:{id}");
super::download_to(&client, spec.url, &tmp, progress, &pid).await?;
let expected = spec.sha256.to_string();
let tmp2 = tmp.clone();
let dest2 = dest.clone();
let p = progress.clone();
let pid2 = pid.clone();
tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
super::report(
&p,
&pid2,
"verify",View on GitHub (pinned to 8600b91f42)