Skip to content

Commit 2522b71

Browse files
authored
fix(deep-link): revert the breaking change introduced by #2928 (#2970)
1 parent 9021a73 commit 2522b71

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

.changes/fix-deep-link-semver.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deep-link: patch
3+
deep-link-js: patch
4+
---
5+
6+
Revert the breaking change introduced by [#2928](https://github.com/tauri-apps/plugins-workspace/pull/2928).

plugins/deep-link/src/error.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ pub enum Error {
2323
#[cfg(target_os = "linux")]
2424
#[error(transparent)]
2525
ParseIni(#[from] ini::ParseError),
26-
#[cfg(target_os = "linux")]
27-
#[error("Failed to run OS command `{0}`: {1}")]
28-
Execute(&'static str, #[source] std::io::Error),
2926
#[cfg(mobile)]
3027
#[error(transparent)]
3128
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
3229
}
3330

31+
// TODO(v3): change this into an error in v3,
32+
// see <https://github.com/tauri-apps/plugins-workspace/pull/2970#issuecomment-3244660138>.
33+
#[inline]
34+
#[cfg(target_os = "linux")]
35+
pub(crate) fn inspect_command_error<'a>(command: &'a str) -> impl Fn(&std::io::Error) + 'a {
36+
move |e| {
37+
tracing::error!("Failed to run OS command `{command}`: {e}");
38+
}
39+
}
40+
3441
impl Serialize for Error {
3542
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3643
where

plugins/deep-link/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,14 @@ mod imp {
334334
Command::new("update-desktop-database")
335335
.arg(target)
336336
.status()
337-
.map_err(|error| crate::Error::Execute("update-desktop-database", error))?;
337+
.inspect_err(crate::error::inspect_command_error(
338+
"update-desktop-database",
339+
))?;
338340

339341
Command::new("xdg-mime")
340342
.args(["default", &file_name, mime_type.as_str()])
341343
.status()
342-
.map_err(|error| crate::Error::Execute("xdg-mime", error))?;
344+
.inspect_err(crate::error::inspect_command_error("xdg-mime"))?;
343345

344346
Ok(())
345347
}
@@ -444,7 +446,7 @@ mod imp {
444446
&format!("x-scheme-handler/{}", _protocol.as_ref()),
445447
])
446448
.output()
447-
.map_err(|error| crate::Error::Execute("xdg-mime", error))?;
449+
.inspect_err(crate::error::inspect_command_error("xdg-mime"))?;
448450

449451
Ok(String::from_utf8_lossy(&output.stdout).contains(&file_name))
450452
}

0 commit comments

Comments
 (0)