Remove mod #11
This commit is contained in:
@@ -105,6 +105,26 @@ fn fallback_mod(file_name: &str, enabled: bool) -> Mod {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn remove_mod(version: String, file_name: String) -> Result<(), String> {
|
||||
// mods folder
|
||||
let mods_dir: PathBuf = LAUNCHER_DIR.data_dir().join(&version).join("mods");
|
||||
|
||||
// File to remove
|
||||
let source = mods_dir.join(&file_name);
|
||||
|
||||
if !source.exists() {
|
||||
return Err(format!("Mod file not found: {}", file_name));
|
||||
}
|
||||
|
||||
// move file
|
||||
fs::remove_file(&source)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn disable_mod(version: String, file_name: String) -> Result<(), String> {
|
||||
// mods folder
|
||||
|
||||
@@ -12,9 +12,10 @@ fn main() {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
// Saturn Launcher Commands
|
||||
saturn_launcher_lib::commands::get_installed_mods,
|
||||
saturn_launcher_lib::commands::install_mod,
|
||||
saturn_launcher_lib::commands::enable_mod,
|
||||
saturn_launcher_lib::commands::disable_mod,
|
||||
saturn_launcher_lib::commands::install_mod,
|
||||
saturn_launcher_lib::commands::remove_mod,
|
||||
saturn_launcher_lib::commands::get_settings,
|
||||
saturn_launcher_lib::commands::update_settings,
|
||||
saturn_launcher_lib::commands::get_version,
|
||||
|
||||
Reference in New Issue
Block a user