File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " tauri " : patch
3+ ---
4+
5+ Validate dialog option ` defaultPath ` - it must exists.
Original file line number Diff line number Diff line change @@ -144,6 +144,9 @@ fn set_default_path(
144144pub fn open ( options : OpenDialogOptions ) -> crate :: Result < InvokeResponse > {
145145 let mut dialog_builder = FileDialogBuilder :: new ( ) ;
146146 if let Some ( default_path) = options. default_path {
147+ if !default_path. exists ( ) {
148+ return Err ( crate :: Error :: DialogDefaultPathNotExists ( default_path) ) ;
149+ }
147150 dialog_builder = set_default_path ( dialog_builder, default_path) ;
148151 }
149152 for filter in options. filters {
@@ -165,6 +168,9 @@ pub fn open(options: OpenDialogOptions) -> crate::Result<InvokeResponse> {
165168pub fn save ( options : SaveDialogOptions ) -> crate :: Result < InvokeResponse > {
166169 let mut dialog_builder = FileDialogBuilder :: new ( ) ;
167170 if let Some ( default_path) = options. default_path {
171+ if !default_path. exists ( ) {
172+ return Err ( crate :: Error :: DialogDefaultPathNotExists ( default_path) ) ;
173+ }
168174 dialog_builder = set_default_path ( dialog_builder, default_path) ;
169175 }
170176 for filter in options. filters {
Original file line number Diff line number Diff line change 22// SPDX-License-Identifier: Apache-2.0
33// SPDX-License-Identifier: MIT
44
5+ use std:: path:: PathBuf ;
6+
57/// Runtime errors that can happen inside a Tauri application.
68#[ derive( Debug , thiserror:: Error ) ]
79pub enum Error {
@@ -60,6 +62,9 @@ pub enum Error {
6062 /// Error initializing plugin.
6163 #[ error( "failed to initialize plugin `{0}`: {1}" ) ]
6264 PluginInitialization ( String , String ) ,
65+ /// `default_path` provided to dialog API doesn't exist.
66+ #[ error( "failed to setup dialog: provided default path `{0}` doesn't exist" ) ]
67+ DialogDefaultPathNotExists ( PathBuf ) ,
6368}
6469
6570impl From < serde_json:: Error > for Error {
You can’t perform that action at this time.
0 commit comments