This commit is contained in:
Julian Freeman
2026-03-01 19:30:08 -04:00
commit ebef785f9a
40 changed files with 7314 additions and 0 deletions

43
src-tauri/src/lib.rs Normal file
View File

@@ -0,0 +1,43 @@
mod cleaner;
use tauri::State;
use std::collections::HashMap;
use std::sync::Mutex;
#[tauri::command]
async fn start_fast_scan() -> cleaner::FastScanResult {
cleaner::run_fast_scan().await
}
#[tauri::command]
async fn start_fast_clean(is_simulation: bool) -> Result<String, String> {
cleaner::run_fast_clean(is_simulation).await
}
#[tauri::command]
async fn start_full_disk_scan(state: State<'_, cleaner::DiskState>) -> Result<(), String> {
cleaner::run_full_scan("C:\\".to_string(), &state).await;
Ok(())
}
#[tauri::command]
async fn get_tree_children(path: String, state: State<'_, cleaner::DiskState>) -> Result<Vec<cleaner::FileTreeNode>, String> {
Ok(cleaner::get_children(path, &state))
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.manage(cleaner::DiskState {
dir_sizes: Mutex::new(HashMap::new()),
file_info: Mutex::new(HashMap::new()),
})
.invoke_handler(tauri::generate_handler![
start_fast_scan,
start_fast_clean,
start_full_disk_scan,
get_tree_children
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}