fix(fs): ignore OS specific paths in scope deserialization (#1837)

pull/1458/merge
Fabian-Lars 8 months ago committed by GitHub
parent b7ff3a6bdb
commit fc9b189e83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
fs: patch
---
Fix failing to deserialize capability file when using an OS specific path in the scope that is not available on the current OS.

@ -993,8 +993,8 @@ pub fn resolve_path<R: Runtime>(
.unwrap()
.clone()
.into_iter()
.chain(global_scope.allows().iter().map(|e| e.path.clone()))
.chain(command_scope.allows().iter().map(|e| e.path.clone()))
.chain(global_scope.allows().iter().filter_map(|e| e.path.clone()))
.chain(command_scope.allows().iter().filter_map(|e| e.path.clone()))
.collect(),
deny: webview
.fs_scope()
@ -1003,8 +1003,8 @@ pub fn resolve_path<R: Runtime>(
.unwrap()
.clone()
.into_iter()
.chain(global_scope.denies().iter().map(|e| e.path.clone()))
.chain(command_scope.denies().iter().map(|e| e.path.clone()))
.chain(global_scope.denies().iter().filter_map(|e| e.path.clone()))
.chain(command_scope.denies().iter().filter_map(|e| e.path.clone()))
.collect(),
require_literal_leading_dot: webview.fs_scope().require_literal_leading_dot,
},

@ -353,17 +353,17 @@ impl ScopeObject for scope::Entry {
app: &AppHandle<R>,
raw: Value,
) -> std::result::Result<Self, Self::Error> {
let entry = serde_json::from_value(raw.into()).map(|raw| {
let path = match raw {
scope::EntryRaw::Value(path) => path,
scope::EntryRaw::Object { path } => path,
};
Self { path }
let path = serde_json::from_value(raw.into()).map(|raw| match raw {
scope::EntryRaw::Value(path) => path,
scope::EntryRaw::Object { path } => path,
})?;
Ok(Self {
path: app.path().parse(entry.path)?,
})
match app.path().parse(path) {
Ok(path) => Ok(Self { path: Some(path) }),
#[cfg(not(target_os = "android"))]
Err(tauri::Error::UnknownPath) => Ok(Self { path: None }),
Err(err) => Err(err.into()),
}
}
}

@ -23,7 +23,7 @@ pub enum EntryRaw {
#[derive(Debug)]
pub struct Entry {
pub path: PathBuf,
pub path: Option<PathBuf>,
}
pub type EventId = u32;

Loading…
Cancel
Save