feat(dialog) - Support fileAccessMode for open dialog (#3030) - #3136
Conversation
|
c. @velocitysystems Here is the MR for the changes to support |
d4c8e4b to
749a149
Compare
|
|
||
| #[command] | ||
| pub(crate) async fn end_file_access<R: Runtime>( | ||
| _window: Window<R>, |
There was a problem hiding this comment.
_window is unused here.
There was a problem hiding this comment.
My understanding is that the window parameter is required for commands to be invoked; is that incorrect?
There was a problem hiding this comment.
According to Tauri's documentation, Window, AppHandle, and State<T> are "Special Parameters" that are automatically injected by the #[tauri::command] macro if present, but they're not required.
Since end_file_access doesn't use the window for anything (no scope management, no parent window needed), it can safely be removed.
There was a problem hiding this comment.
When I remove the initial argument, we get a compilation error related to where we register the handler:
plugins/dialog/src/commands.rs:427:1
|
427 | #[command]
| ^^^^^^^^^^ cannot infer type
|
::: plugins/dialog/src/lib.rs:203:25
|
203 | .invoke_handler(tauri::generate_handler![
| _________________________-
204 | | commands::open,
205 | | commands::save,
206 | | commands::message,
... |
210 | | commands::end_file_access,
211 | | ])
| |_________- in this macro invocation
|
= note: cannot satisfy `_: tauri::Runtime`
note: required by a bound in `end_file_access`
--> plugins/dialog/src/commands.rs:428:40
|
428 | pub(crate) async fn end_file_access<R: Runtime>(We can at least change the argument to an AppHandle instead of a Window, but removing the parameter will cause a compilation error.
Is there something I am missing with this?
fcbcbd9 to
16dea72
Compare
16dea72 to
8cd49a2
Compare
8cd49a2 to
03e6dad
Compare
|
Updated MR per discussion in #3185 ; we now only include support for |
On iOS, when trying to access a file that exists outside of the app sandbox, one of 2 things need to happen to be able to perform any operations on said file: * A copy of the file needs to be made to the internal app sandbox * The method startAccessingSecurityScopedResource needs to be called. Previously, a copy of the file was always being made when a file was selected through the picker dialog. While this did ensure there were no file access exceptions when reading from the file, it does not scale well for large files. To resolve this, we now support `fileAccessMode`, which allows a file handle to be returned without copying the file to the app sandbox. This MR only supports this change for iOS; MacOS has a different set of needs for security scoped resources. See discussion in #3716 for more discussion of the difference between iOS and MacOS. See MR tauri-apps#3185 to see how these scoped files will be accessible using security scoping.
03e6dad to
03093d4
Compare
Package Changes Through 098ddafThere are 4 changes which include dialog with minor, dialog-js with minor, updater with minor, updater-js with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
… (tauri-apps#3136) * feat(dialog) - Support fileAccessMode for open dialog (tauri-apps#3030) On iOS, when trying to access a file that exists outside of the app sandbox, one of 2 things need to happen to be able to perform any operations on said file: * A copy of the file needs to be made to the internal app sandbox * The method startAccessingSecurityScopedResource needs to be called. Previously, a copy of the file was always being made when a file was selected through the picker dialog. While this did ensure there were no file access exceptions when reading from the file, it does not scale well for large files. To resolve this, we now support `fileAccessMode`, which allows a file handle to be returned without copying the file to the app sandbox. This MR only supports this change for iOS; MacOS has a different set of needs for security scoped resources. See discussion in #3716 for more discussion of the difference between iOS and MacOS. See MR tauri-apps#3185 to see how these scoped files will be accessible using security scoping. * fmt, clippy * use enum --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
On iOS, when trying to access a file that exists outside of the app sandbox, one of 2 things need to happen to be able to perform any operations on said file:
Previously, a copy of the file was always being made when a file was selected through the picker dialog.
While this did ensure there were no file access exceptions when reading from the file, it does not scale well for large files.
To resolve this, we now support
fileAccessMode, which allows a file handle to be returned without copying the file to the app sandbox.This MR only supports this change for iOS; MacOS has a different set of needs for security scoped resources.
See discussion in #3716 for more discussion of the difference between iOS and MacOS.
See MR #3185 to see how these scoped files will be accessible using security scoping.