Skip to content

Commit 0197a7e

Browse files
committed
Okay tauri I am not dealing with your permission nonsense
1 parent 5c8fffa commit 0197a7e

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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,

src-tauri/src/utils.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

src/views/Library.vue

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import WidgetRawData from '@components/library/widgets/WidgetRawData.vue';
55
import { invoke } from '@tauri-apps/api/core';
66
import { UnlistenFn, listen } from '@tauri-apps/api/event';
77
import { open } from '@tauri-apps/plugin-dialog';
8-
import { exists, readDir } from '@tauri-apps/plugin-fs';
98
import {
109
ScrollAreaRoot,
1110
ScrollAreaScrollbar,
@@ -40,19 +39,12 @@ const hoverState = ref<HoverState>({
4039
const hoverListeners: UnlistenFn[] = [];
4140
4241
async 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
5850
async function addEngineFromFolder(folderPath: string): Promise<void> {

0 commit comments

Comments
 (0)