Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

fix(deps): report the PDFium the user pointed at (#296)

antoniocea3bcb92503
diff --git a/src-tauri/omniget-core/src/core/pdfium.rs b/src-tauri/omniget-core/src/core/pdfium.rs
index 88306683..cf324bbd 100644
--- a/src-tauri/omniget-core/src/core/pdfium.rs
+++ b/src-tauri/omniget-core/src/core/pdfium.rs
@@ -114,8 +114,33 @@ pub fn pdfium_version_marker_path() -> Option<PathBuf> {
pdfium_target_dir().map(|d| d.join("pdfium.version"))
}
+/// The PDFium library actually in use, and where it came from: `"custom"` for
+/// a file the user pointed at, `"managed"` for the one OmniGet downloaded.
+///
+/// Issue #222: yt-dlp and FFmpeg have honoured the user's own binary since
+/// the feature shipped, through `find_tool_with_source`. PDFium never did —
+/// only the managed folder was ever checked — so a linked library was
+/// recorded and displayed while the status stayed "missing".
+pub fn resolve_with_source() -> Option<(PathBuf, &'static str)> {
+ if let Some(custom) = crate::core::binary_overrides::get("PDFium") {
+ if custom.is_file() {
+ return Some((custom, "custom"));
+ }
+ }
+ let managed = pdfium_target_path()?;
+ if managed.is_file() {
+ return Some((managed, "managed"));
+ }
+ None
+}
+
+/// Path to the PDFium library to load, honouring a custom override.
+pub fn resolve_path() -> Option<PathBuf> {
+ resolve_with_source().map(|(p, _)| p)
+}
+
pub fn is_installed() -> bool {
- pdfium_target_path().map(|p| p.is_file()).unwrap_or(false)
+ resolve_with_source().is_some()
}
pub fn read_version_marker() -> Option<String> {
diff --git a/src-tauri/src/commands/dependencies.rs b/src-tauri/src/commands/dependencies.rs
index 33e6be3b..54663f55 100644
--- a/src-tauri/src/commands/dependencies.rs
+++ b/src-tauri/src/commands/dependencies.rs
@@ -48,7 +48,8 @@ pub async fn check_dependencies() -> Result<Vec<DependencyStatus>, String> {
},
);
- let pdfium_installed = pdfium::is_installed();
+ let pdfium_resolved = pdfium::resolve_with_source();
+ let pdfium_installed = pdfium_resolved.is_some();
let pdfium_version = if pdfium_installed {
Some(pdfium::read_version_marker().unwrap_or_else(|| "installed".to_string()))
} else {
@@ -94,14 +95,16 @@ pub async fn check_dependencies() -> Result<Vec<DependencyStatus>, String> {
name: "PDFium".into(),
installed: pdfium_installed,
version: pdfium_version,
- source: if pdfium_installed {
- "managed".into()
- } else {
- "missing".into()
- },
- path: pdfium::pdfium_target_dir()
- .filter(|_| pdfium_installed)
- .map(|p| p.to_string_lossy().to_string()),
+ source: pdfium_resolved
+ .as_ref()
+ .map(|(_, s)| (*s).to_string())
+ .unwrap_or_else(|| "missing".to_string()),
+ // The resolved library, not the managed folder: with a custom
+ // path those are different places, and naming the folder there
+ // would point at something the app is not using.
+ path: pdfium_resolved
+ .as_ref()
+ .map(|(p, _)| p.to_string_lossy().to_string()),
outdated: false,
},
])