anshdadhich commited on
Commit
6b4cf15
Β·
verified Β·
1 Parent(s): 6251a5e

Upload fastsearch-tauri/src-tauri/src/main.rs

Browse files
fastsearch-tauri/src-tauri/src/main.rs CHANGED
@@ -20,7 +20,7 @@ use fastsearch_core::mft::watcher::UsnWatcher;
20
  use fastsearch_core::mft::types::{IndexEvent, JournalCheckpoint};
21
  use fastsearch_core::utils::drives::get_ntfs_drives;
22
 
23
- // ── Global state ───────────────────────────────────────────────────
24
  static INDEX: Lazy<Arc<RwLock<IndexStore>>> = Lazy::new(|| {
25
  Arc::new(RwLock::new(IndexStore::new()))
26
  });
@@ -33,7 +33,7 @@ static EXCLUDED_DIRS: Lazy<Arc<RwLock<Vec<String>>>> = Lazy::new(|| {
33
  Arc::new(RwLock::new(load_exclusions()))
34
  });
35
 
36
- // ── Search response types ─────────────────────────────────────────
37
  #[derive(Serialize, Clone)]
38
  struct SearchResponse {
39
  results: Vec<SearchItem>,
@@ -58,7 +58,7 @@ struct SearchRequest {
58
  case_sensitive: bool,
59
  }
60
 
61
- // ── Tauri Commands ─────────────────────────────────────────────────
62
  #[tauri::command]
63
  fn cmd_search(request: SearchRequest) -> SearchResponse {
64
  let store = INDEX.read();
@@ -149,7 +149,7 @@ fn cmd_get_exclusions() -> Vec<String> {
149
  EXCLUDED_DIRS.read().clone()
150
  }
151
 
152
- // ── Window helpers ───────────────────────────────────────────────
153
  fn toggle_window(window: &tauri::WebviewWindow) {
154
  if window.is_visible().unwrap_or(false) {
155
  let _ = window.hide();
@@ -173,7 +173,7 @@ fn show_window(window: &tauri::WebviewWindow) {
173
  }
174
  }
175
 
176
- // ── Config helpers ───────────────────────────────────────────────
177
  fn config_dir() -> std::path::PathBuf {
178
  let dir = std::env::var("APPDATA")
179
  .map(std::path::PathBuf::from)
@@ -199,7 +199,7 @@ fn save_exclusions(dirs: &[String]) {
199
  let _ = std::fs::write(&path, content);
200
  }
201
 
202
- // ── Index initialization (background thread) ──────────────────
203
  fn init_index() {
204
  std::thread::spawn(|| {
205
  let drives = get_ntfs_drives();
@@ -360,7 +360,7 @@ fn init_index() {
360
  });
361
  }
362
 
363
- // ── Main ───────────────────────────────────────────────────────────
364
  fn main() {
365
  tauri::Builder::default()
366
  .plugin(tauri_plugin_global_shortcut::Builder::new().build())
@@ -369,7 +369,7 @@ fn main() {
369
  // Initialize index in background
370
  init_index();
371
 
372
- // ── Tray Icon ──────────────────────────────────────────
373
  let show = MenuItemBuilder::with_id("show", "Show").build(app)?;
374
  let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
375
  let menu = MenuBuilder::new(app).items(&[&show, &quit]).build()?;
@@ -402,7 +402,7 @@ fn main() {
402
  })
403
  .build(app)?;
404
 
405
- // ── Global Shortcut (Win+Space) ──────────────────────
406
  app.handle().plugin(
407
  tauri_plugin_global_shortcut::Builder::new()
408
  .with_handler(|app, shortcut, event| {
 
20
  use fastsearch_core::mft::types::{IndexEvent, JournalCheckpoint};
21
  use fastsearch_core::utils::drives::get_ntfs_drives;
22
 
23
+ // -- Global state --------------------------------------------------
24
  static INDEX: Lazy<Arc<RwLock<IndexStore>>> = Lazy::new(|| {
25
  Arc::new(RwLock::new(IndexStore::new()))
26
  });
 
33
  Arc::new(RwLock::new(load_exclusions()))
34
  });
35
 
36
+ // -- Search response types ----------------------------------------
37
  #[derive(Serialize, Clone)]
38
  struct SearchResponse {
39
  results: Vec<SearchItem>,
 
58
  case_sensitive: bool,
59
  }
60
 
61
+ // -- Tauri Commands ------------------------------------------------
62
  #[tauri::command]
63
  fn cmd_search(request: SearchRequest) -> SearchResponse {
64
  let store = INDEX.read();
 
149
  EXCLUDED_DIRS.read().clone()
150
  }
151
 
152
+ // -- Window helpers ------------------------------------------------
153
  fn toggle_window(window: &tauri::WebviewWindow) {
154
  if window.is_visible().unwrap_or(false) {
155
  let _ = window.hide();
 
173
  }
174
  }
175
 
176
+ // -- Config helpers ------------------------------------------------
177
  fn config_dir() -> std::path::PathBuf {
178
  let dir = std::env::var("APPDATA")
179
  .map(std::path::PathBuf::from)
 
199
  let _ = std::fs::write(&path, content);
200
  }
201
 
202
+ // -- Index initialization (background thread) -------------------
203
  fn init_index() {
204
  std::thread::spawn(|| {
205
  let drives = get_ntfs_drives();
 
360
  });
361
  }
362
 
363
+ // -- Main ----------------------------------------------------------
364
  fn main() {
365
  tauri::Builder::default()
366
  .plugin(tauri_plugin_global_shortcut::Builder::new().build())
 
369
  // Initialize index in background
370
  init_index();
371
 
372
+ // -- Tray Icon -----------------------------------------
373
  let show = MenuItemBuilder::with_id("show", "Show").build(app)?;
374
  let quit = MenuItemBuilder::with_id("quit", "Quit").build(app)?;
375
  let menu = MenuBuilder::new(app).items(&[&show, &quit]).build()?;
 
402
  })
403
  .build(app)?;
404
 
405
+ // -- Global Shortcut (Win+Space) ---------------------
406
  app.handle().plugin(
407
  tauri_plugin_global_shortcut::Builder::new()
408
  .with_handler(|app, shortcut, event| {