{"record":{"id":"887adee70d792ad3","repo":"tonhowtf/omniget","slug":"n-o-um-arquivo","errorCode":null,"errorMessage":"{} não é um arquivo","messagePattern":"(.+?) não é um arquivo","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/onnxrt.rs","lineNumber":516,"sourceCode":"        let canonical = make_canonical(&dir_for_task, &extracted)?;\n        let _ = std::fs::remove_file(&tmp_for_task);\n        Ok(canonical)\n    })\n    .await\n    .map_err(|e| anyhow!(\"tarefa de extração falhou: {e}\"))??;\n\n    if let Some(marker) = version_marker_path() {\n        let _ = std::fs::write(&marker, format!(\"{} ({})\", RUNTIME_VERSION, asset.file));\n    }\n    strip_quarantine(&out).await;\n    crate::core::tools::report(progress, \"onnxruntime\", \"done\", 1, Some(1), None);\n    Ok(out)\n}\n\n/// Instala a partir de um arquivo que o usuário já tem no disco.\npub fn install_from_path(source: &Path) -> anyhow::Result<PathBuf> {\n    if !source.is_file() {\n        return Err(anyhow!(\"{} não é um arquivo\", source.display()));\n    }\n    let name = source\n        .file_name()\n        .and_then(|s| s.to_str())\n        .unwrap_or_default();\n    if !is_runtime_lib(name) {\n        return Err(anyhow!(\n            \"{} não parece a biblioteca do ONNX Runtime deste sistema (esperava algo como {})\",\n            name,\n            lib_filename()\n        ));\n    }\n    let dir = target_dir().ok_or_else(|| anyhow!(\"não achei o diretório de dados do app\"))?;\n    std::fs::create_dir_all(&dir).with_context(|| format!(\"criando {}\", dir.display()))?;\n    let bytes = std::fs::read(source).with_context(|| format!(\"lendo {}\", source.display()))?;\n    let dest = write_atomic(&dir, lib_filename(), &bytes)?;\n    if let Some(marker) = version_marker_path() {\n        let _ = std::fs::write(&marker, format!(\"local ({name})\"));","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/onnxrt.rs#L498-L534","documentation":"Raised by install_from_path() when the user-supplied path is not a regular file (is_file() false): directories, broken symlinks, or nonexistent paths all fail here. The library validates the input early because it will read the file bytes next.","triggerScenarios":"install_from_path(path) called with a directory, a dangling symlink, or a path that does not exist — typically a user-picked path passed through without normalization.","commonSituations":"User drags a folder instead of the .so/.dll/.dylib; path contains shell globs resolved wrongly; symlink to a lib that was moved; empty path from a cancelled file dialog.","solutions":["Pass the exact path to the shared library file (e.g. libonnxruntime.so), not its directory","Check the path exists and is a regular file before calling (std::fs::metadata(path).is_file())","Resolve symlinks with std::fs::canonicalize before calling","Re-run the file picker to get a valid selection"],"exampleFix":"// before\nonnxrt::install_from_path(Path::new(\"~/Downloads/onnxruntime/\"))?; // directory\n// after\nlet p = std::fs::canonicalize(\"~/Downloads/onnxruntime/lib/libonnxruntime.so\")?;\ndebug_assert!(p.is_file());\nonnxrt::install_from_path(&p)?;","handlingStrategy":"type-guard","validationCode":"if !src.is_file() { return Err(anyhow!(\"{} is not a file\", src.display())); }","typeGuard":"fn is_regular_file(p: &std::path::Path) -> bool { std::fs::metadata(p).map(|m| m.is_file()).unwrap_or(false) }","tryCatchPattern":"match onnxrt::install_from_path(&p) { Err(e) if e.to_string().contains(\"não é um arquivo\") => show_file_picker_again(), ... }","preventionTips":["Canonicalize user-supplied paths before calling","Use a file dialog restricted to library file types","Reject directory picks in the UI layer"],"tags":["rust","filesystem","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}