Skip to content

Commit fc9b189

Browse files
authored
fix(fs): ignore OS specific paths in scope deserialization (#1837)
1 parent b7ff3a6 commit fc9b189

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fs: patch
3+
---
4+
5+
Fix failing to deserialize capability file when using an OS specific path in the scope that is not available on the current OS.

plugins/fs/src/commands.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ pub fn resolve_path<R: Runtime>(
993993
.unwrap()
994994
.clone()
995995
.into_iter()
996-
.chain(global_scope.allows().iter().map(|e| e.path.clone()))
997-
.chain(command_scope.allows().iter().map(|e| e.path.clone()))
996+
.chain(global_scope.allows().iter().filter_map(|e| e.path.clone()))
997+
.chain(command_scope.allows().iter().filter_map(|e| e.path.clone()))
998998
.collect(),
999999
deny: webview
10001000
.fs_scope()
@@ -1003,8 +1003,8 @@ pub fn resolve_path<R: Runtime>(
10031003
.unwrap()
10041004
.clone()
10051005
.into_iter()
1006-
.chain(global_scope.denies().iter().map(|e| e.path.clone()))
1007-
.chain(command_scope.denies().iter().map(|e| e.path.clone()))
1006+
.chain(global_scope.denies().iter().filter_map(|e| e.path.clone()))
1007+
.chain(command_scope.denies().iter().filter_map(|e| e.path.clone()))
10081008
.collect(),
10091009
require_literal_leading_dot: webview.fs_scope().require_literal_leading_dot,
10101010
},

plugins/fs/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,17 +353,17 @@ impl ScopeObject for scope::Entry {
353353
app: &AppHandle<R>,
354354
raw: Value,
355355
) -> std::result::Result<Self, Self::Error> {
356-
let entry = serde_json::from_value(raw.into()).map(|raw| {
357-
let path = match raw {
358-
scope::EntryRaw::Value(path) => path,
359-
scope::EntryRaw::Object { path } => path,
360-
};
361-
Self { path }
356+
let path = serde_json::from_value(raw.into()).map(|raw| match raw {
357+
scope::EntryRaw::Value(path) => path,
358+
scope::EntryRaw::Object { path } => path,
362359
})?;
363360

364-
Ok(Self {
365-
path: app.path().parse(entry.path)?,
366-
})
361+
match app.path().parse(path) {
362+
Ok(path) => Ok(Self { path: Some(path) }),
363+
#[cfg(not(target_os = "android"))]
364+
Err(tauri::Error::UnknownPath) => Ok(Self { path: None }),
365+
Err(err) => Err(err.into()),
366+
}
367367
}
368368
}
369369

plugins/fs/src/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub enum EntryRaw {
2323

2424
#[derive(Debug)]
2525
pub struct Entry {
26-
pub path: PathBuf,
26+
pub path: Option<PathBuf>,
2727
}
2828

2929
pub type EventId = u32;

0 commit comments

Comments
 (0)