mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-10-10 22:38:44 +02:00
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:
1 parent
3a9000177c
commit
e03dca60e7
2 files changed
+16
-4
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
fs: patch
|
||||
fs-js: patch
|
||||
---
|
||||
|
||||
`startAccessingSecurityScopedResource` and `stopAccessingSecurityScopedResource` now accept absolute paths on iOS, as documented, instead of silently doing nothing unless given a `file://` URL.
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user