mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
fix(deep-link): Add command name to linux errors (#2928)
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
deep-link: patch
|
||||||
|
deep-link-js: patch
|
||||||
|
---
|
||||||
|
|
||||||
|
On Linux, improved error messages when OS commands fail.
|
||||||
@@ -23,6 +23,9 @@ pub enum Error {
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
ParseIni(#[from] ini::ParseError),
|
ParseIni(#[from] ini::ParseError),
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
#[error("Failed to run OS command `{0}`: {1}")]
|
||||||
|
Execute(&'static str, #[source] std::io::Error),
|
||||||
#[cfg(mobile)]
|
#[cfg(mobile)]
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
|
PluginInvoke(#[from] tauri::plugin::mobile::PluginInvokeError),
|
||||||
|
|||||||
@@ -254,6 +254,7 @@ mod imp {
|
|||||||
///
|
///
|
||||||
/// ## Platform-specific:
|
/// ## Platform-specific:
|
||||||
///
|
///
|
||||||
|
/// - **Linux**: Needs the `xdg-mime` and `update-desktop-database` commands available on the system.
|
||||||
/// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`).
|
/// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`).
|
||||||
pub fn register<S: AsRef<str>>(&self, _protocol: S) -> crate::Result<()> {
|
pub fn register<S: AsRef<str>>(&self, _protocol: S) -> crate::Result<()> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -332,11 +333,13 @@ mod imp {
|
|||||||
|
|
||||||
Command::new("update-desktop-database")
|
Command::new("update-desktop-database")
|
||||||
.arg(target)
|
.arg(target)
|
||||||
.status()?;
|
.status()
|
||||||
|
.map_err(|error| crate::Error::Execute("update-desktop-database", error))?;
|
||||||
|
|
||||||
Command::new("xdg-mime")
|
Command::new("xdg-mime")
|
||||||
.args(["default", &file_name, mime_type.as_str()])
|
.args(["default", &file_name, mime_type.as_str()])
|
||||||
.status()?;
|
.status()
|
||||||
|
.map_err(|error| crate::Error::Execute("xdg-mime", error))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -405,6 +408,7 @@ mod imp {
|
|||||||
///
|
///
|
||||||
/// ## Platform-specific:
|
/// ## Platform-specific:
|
||||||
///
|
///
|
||||||
|
/// - **Linux**: Needs the `xdg-mime` command available on the system.
|
||||||
/// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`).
|
/// - **macOS / Android / iOS**: Unsupported, will return [`Error::UnsupportedPlatform`](`crate::Error::UnsupportedPlatform`).
|
||||||
pub fn is_registered<S: AsRef<str>>(&self, _protocol: S) -> crate::Result<bool> {
|
pub fn is_registered<S: AsRef<str>>(&self, _protocol: S) -> crate::Result<bool> {
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@@ -439,7 +443,8 @@ mod imp {
|
|||||||
"default",
|
"default",
|
||||||
&format!("x-scheme-handler/{}", _protocol.as_ref()),
|
&format!("x-scheme-handler/{}", _protocol.as_ref()),
|
||||||
])
|
])
|
||||||
.output()?;
|
.output()
|
||||||
|
.map_err(|error| crate::Error::Execute("xdg-mime", error))?;
|
||||||
|
|
||||||
Ok(String::from_utf8_lossy(&output.stdout).contains(&file_name))
|
Ok(String::from_utf8_lossy(&output.stdout).contains(&file_name))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user