{"record":{"id":"5280baa527768719","repo":"tonhowtf/omniget","slug":"source-not-a-file","errorCode":null,"errorMessage":"source not a file: {}","messagePattern":"source not a file: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/pdfium.rs","lineNumber":229,"sourceCode":"    {\n        let _ = tokio::task::spawn_blocking({\n            let p = target_path.clone();\n            move || {\n                crate::core::process::std_command(\"xattr\")\n                    .args([\"-d\", \"com.apple.quarantine\"])\n                    .arg(&p)\n                    .output()\n            }\n        })\n        .await;\n    }\n\n    Ok(target_path)\n}\n\npub fn set_pdfium_from_path(source: &Path) -> anyhow::Result<PathBuf> {\n    if !source.is_file() {\n        return Err(anyhow!(\"source not a file: {}\", source.display()));\n    }\n    let target_dir =\n        pdfium_target_dir().ok_or_else(|| anyhow!(\"could not determine app data dir\"))?;\n    std::fs::create_dir_all(&target_dir)\n        .with_context(|| format!(\"creating pdfium target dir {}\", target_dir.display()))?;\n    let lib_filename = pdfium_lib_filename();\n    let target_path = target_dir.join(lib_filename);\n\n    let tmp = target_dir.join(format!(\".{}.tmp\", lib_filename));\n    std::fs::copy(source, &tmp)\n        .with_context(|| format!(\"copying {} → {}\", source.display(), tmp.display()))?;\n    if target_path.exists() {\n        let _ = std::fs::remove_file(&target_path);\n    }\n    std::fs::rename(&tmp, &target_path)\n        .with_context(|| format!(\"renaming temp to {}\", target_path.display()))?;\n\n    if let Some(version_marker) = pdfium_version_marker_path() {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/pdfium.rs#L211-L247","documentation":"set_pdfium_from_path() installs a pdfium shared library from a user-supplied path. Before doing anything it verifies the source path is an existing regular file; directories, symlinks to nothing, or nonexistent paths are rejected with this error that echoes the path via Display.","triggerScenarios":"Calling set_pdfium_from_path() with a path that does not exist, points to a directory, or is a broken symlink — e.g. a typo'd path or passing the extracted archive directory instead of the .so/.dll inside it.","commonSituations":"User selects a folder instead of the library file in a picker; pointing at the downloaded .tar.gz instead of the extracted library; path moved after download.","solutions":["Pass the actual shared library file (e.g. libpdfium.so / pdfium.dll), not a directory or the archive","Check the path exists with std::path::Path::is_file() before calling","If starting from the downloaded archive, extract it first and locate pdfium_lib_filename() within","Re-run ensure_pdfium() to get a valid library if the local copy is missing"],"exampleFix":"// before\nset_pdfium_from_path(Path::new(\"~/Downloads/pdfium\")).await?;\n// after\nlet lib = Path::new(\"~/Downloads/pdfium/libpdfium.so\");\nif !lib.is_file() { panic!(\"select the library file, not the folder\"); }\nset_pdfium_from_path(lib).await?;","handlingStrategy":"validation","validationCode":"let p = std::path::Path::new(source);\nif !p.is_file() {\n    eprintln!(\"{} is not a file — select the pdfium library itself\", p.display());\n}","typeGuard":"fn is_regular_file(p: &std::path::Path) -> bool {\n    p.is_file() && std::fs::metadata(p).map(|m| m.len() > 0).unwrap_or(false)\n}","tryCatchPattern":"match set_pdfium_from_path(src) {\n    Err(e) if e.to_string().contains(\"source not a file\") => {\n        // prompt user to pick the library file, not a directory/archive\n    }\n    other => other.map(|_| ()),\n}","preventionTips":["In file pickers, filter to shared-library extensions (.so/.dll/.dylib)","Resolve symlinks and expand ~ before passing paths","Validate is_file() in the UI layer before calling the API"],"tags":["rust","filesystem","validation","pdfium"],"backgroundTag":"file-not-found","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"}