fix(fs): accept absolute paths in the iOS security-scope commands (#3628)

In plugins/fs/src/commands.rs, start/stop_accessing_security_scoped_resource
only handled SafeFilePath::Url, so a plain path was a silent no-op
although the JS docs say "path or file:// URL" (and
Fs::stop_accessing_security_scoped_resource accepts paths).

Absolute paths are now converted to file:// URLs first; relative paths keep
being ignored. iOS-only code: formatted but not compiled here (the iOS
tauri build script fails in this environment).
This commit is contained in:
Lucas Fernandes Nogueira authored and GitHub committed 2026-10-09 13:25:05 -03:00
1 parent 3a9000177c
commit e03dca60e7
2 files changed
+16 -4

No files matched your search

+10 -4
View File
@@ -1311,10 +1311,13 @@ pub fn start_accessing_security_scoped_resource<R: Runtime>(
#[cfg(target_os = "ios")]
{
use crate::FilePath;
// Convert SafeFilePath to FilePath
// Convert SafeFilePath to FilePath, handling absolute paths as `file://` URLs
let file_path: FilePath = match &path {
SafeFilePath::Url(url) => FilePath::Url(url.clone()),
SafeFilePath::Path(safe_path) => FilePath::Path(safe_path.as_ref().to_owned()),
SafeFilePath::Path(safe_path) => match url::Url::from_file_path(safe_path.as_ref()) {
Ok(url) => FilePath::Url(url),
Err(()) => FilePath::Path(safe_path.as_ref().to_owned()),
},
};
// Only handle file URLs
@@ -1382,10 +1385,13 @@ pub fn stop_accessing_security_scoped_resource<R: Runtime>(
#[cfg(target_os = "ios")]
{
use crate::{FilePath, FsExt};
// Convert SafeFilePath to FilePath
// Convert SafeFilePath to FilePath, handling absolute paths as `file://` URLs
let file_path: FilePath = match &path {
SafeFilePath::Url(url) => FilePath::Url(url.clone()),
SafeFilePath::Path(safe_path) => FilePath::Path(safe_path.as_ref().to_owned()),
SafeFilePath::Path(safe_path) => match url::Url::from_file_path(safe_path.as_ref()) {
Ok(url) => FilePath::Url(url),
Err(()) => FilePath::Path(safe_path.as_ref().to_owned()),
},
};
// Only handle file URLs