From af927569de51a494ef7a85b62fb588fd10f751b6 Mon Sep 17 00:00:00 2001 From: Henry Routson Date: Sat, 1 Jul 2023 21:00:12 +1000 Subject: [PATCH 1/3] fix: prevent panic on thread if no mount is selected --- src-tauri/src/search.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src-tauri/src/search.rs b/src-tauri/src/search.rs index cf0e645..62b5526 100644 --- a/src-tauri/src/search.rs +++ b/src-tauri/src/search.rs @@ -73,6 +73,13 @@ pub async fn search_directory( accept_files: bool, accept_directories: bool, ) -> Result, ()> { + + // mount_pnt needs a default value or to be an optional + if mount_pnt == "" { + println!("select a mount point by clicking on an icon"); // move to ui + return Err(()) + } + let start_time = Instant::now(); let mut results: Vec<_> = Vec::new(); From 0c08f6b4c933657951d03f70adb67d58fa706bcd Mon Sep 17 00:00:00 2001 From: Sam <72096531+conaticus@users.noreply.github.com> Date: Sat, 1 Jul 2023 12:36:44 +0100 Subject: [PATCH 2/3] move search volume check to client side --- src-tauri/src/search.rs | 7 ------- src/components/TopBar/SearchBar.tsx | 7 ++++++- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/search.rs b/src-tauri/src/search.rs index 62b5526..cf0e645 100644 --- a/src-tauri/src/search.rs +++ b/src-tauri/src/search.rs @@ -73,13 +73,6 @@ pub async fn search_directory( accept_files: bool, accept_directories: bool, ) -> Result, ()> { - - // mount_pnt needs a default value or to be an optional - if mount_pnt == "" { - println!("select a mount point by clicking on an icon"); // move to ui - return Err(()) - } - let start_time = Instant::now(); let mut results: Vec<_> = Vec::new(); diff --git a/src/components/TopBar/SearchBar.tsx b/src/components/TopBar/SearchBar.tsx index e434507..64e7833 100644 --- a/src/components/TopBar/SearchBar.tsx +++ b/src/components/TopBar/SearchBar.tsx @@ -14,7 +14,7 @@ export interface ISearchFilter { extension: string; acceptFiles: boolean; acceptDirectories: boolean; -} +}`` export default function SearchBar({ currentDirectoryPath, @@ -32,6 +32,11 @@ export default function SearchBar({ const currentPlace = split[split.length - 2]; async function onSearch() { + if (currentVolume.length == 0) { + alert("Please select a volume before searching."); + return; + } + const results = await invoke("search_directory", { query: searchValue, searchDirectory: currentDirectoryPath, From cd8ee34cb4939abbcd04f7638c45ab50b2907e97 Mon Sep 17 00:00:00 2001 From: Sam <72096531+conaticus@users.noreply.github.com> Date: Sat, 1 Jul 2023 12:37:20 +0100 Subject: [PATCH 3/3] fix oopsie (quotes) --- src/components/TopBar/SearchBar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TopBar/SearchBar.tsx b/src/components/TopBar/SearchBar.tsx index 64e7833..5e274c9 100644 --- a/src/components/TopBar/SearchBar.tsx +++ b/src/components/TopBar/SearchBar.tsx @@ -14,7 +14,7 @@ export interface ISearchFilter { extension: string; acceptFiles: boolean; acceptDirectories: boolean; -}`` +} export default function SearchBar({ currentDirectoryPath,