File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ pub fn run() {
8888 utils:: show_main_window,
8989 utils:: get_dir_size,
9090 utils:: launch_executable,
91+ utils:: has_non_directory_path,
9192 // engines.rs
9293 engines:: get_engine_contexts,
9394 engines:: add_engine_context,
Original file line number Diff line number Diff line change @@ -78,3 +78,11 @@ pub fn launch_executable(
7878 . map_err ( |e| format ! ( "Failed to launch executable: {}" , e) ) ?;
7979 return Ok ( ( ) ) ;
8080}
81+
82+ #[ tauri:: command]
83+ pub fn has_non_directory_path ( paths : Vec < String > ) -> bool {
84+ paths. iter ( ) . any ( |raw_path| {
85+ let path = std:: path:: Path :: new ( raw_path. trim ( ) ) ;
86+ !path. exists ( ) || !path. is_dir ( )
87+ } )
88+ }
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import WidgetRawData from '@components/library/widgets/WidgetRawData.vue';
55import { invoke } from ' @tauri-apps/api/core' ;
66import { UnlistenFn , listen } from ' @tauri-apps/api/event' ;
77import { open } from ' @tauri-apps/plugin-dialog' ;
8- import { exists , readDir } from ' @tauri-apps/plugin-fs' ;
98import {
109 ScrollAreaRoot ,
1110 ScrollAreaScrollbar ,
@@ -40,19 +39,12 @@ const hoverState = ref<HoverState>({
4039const hoverListeners: UnlistenFn [] = [];
4140
4241async function hasNonDirectoryPath(paths : string []): Promise <boolean > {
43- for (const path of paths ) {
44- if (! (await exists (path ))) {
45- return true ;
46- }
47-
48- try {
49- await readDir (path );
50- } catch {
51- return true ;
52- }
42+ try {
43+ return await invoke <boolean >(' has_non_directory_path' , { paths });
44+ } catch (error ) {
45+ console .error (' Failed to validate dropped paths:' , { paths , error });
46+ return true ;
5347 }
54-
55- return false ;
5648}
5749
5850async function addEngineFromFolder(folderPath : string ): Promise <void > {
You can’t perform that action at this time.
0 commit comments