Compare commits
2 Commits
9e026e8ac7
...
b615c91c10
Author | SHA1 | Date | |
---|---|---|---|
b615c91c10 | |||
276f208984 |
@ -31,7 +31,7 @@ fn greet(name: &str) -> String {
|
||||
fn main() {
|
||||
prism::install_prism();
|
||||
tauri::Builder::default()
|
||||
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks])
|
||||
.invoke_handler(tauri::generate_handler![greet, modpack::get_modpacks, modpack::launch_modpack])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
|
||||
use crate::ftp;
|
||||
use crate::system_dirs::get_local_data_directory;
|
||||
use crate::system_dirs::{get_local_data_directory, get_prism_executable};
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::process::Command;
|
||||
use std::{io::Cursor, path::PathBuf};
|
||||
use std::io::{Read, Seek};
|
||||
use serde_json::Value;
|
||||
@ -58,7 +59,9 @@ fn check_modpack_needs_update(id: String) -> bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn launch_modpack(id: String){
|
||||
|
||||
if check_modpack_needs_update(id.clone()) {
|
||||
install_modpack(id.clone());
|
||||
}
|
||||
@ -66,7 +69,12 @@ pub fn launch_modpack(id: String){
|
||||
}
|
||||
|
||||
fn install_modpack(id: String){
|
||||
let mut file = File::create(env::temp_dir().join(format!("{}.mrpack", get_modpack_name(id)))).unwrap();
|
||||
let versions = get_versions(id.clone());
|
||||
let path = env::temp_dir().join(format!("{}.mrpack", get_modpack_name(id.clone())));
|
||||
let mut file = File::create(path.clone()).unwrap();
|
||||
ftp::ftp_retr(PathBuf::new().join(id).join(versions[versions.len()-1].version.clone()), file, |_| return);
|
||||
let child = Command::new(get_local_data_directory().join("prism").join(get_prism_executable())).arg("-I").arg(path).spawn().unwrap();
|
||||
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
Loading…
Reference in New Issue
Block a user