Compare commits
No commits in common. "ea766de5c31c2217db74222689cf8ebd875626e7" and "03aadbe9776b02701f075f21bbe2043ad0f1acbe" have entirely different histories.
ea766de5c3
...
03aadbe977
3 changed files with 12 additions and 22 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashMap, error::Error};
|
use std::error::Error;
|
||||||
|
|
||||||
use dialoguer::{FuzzySelect, Select, theme::ColorfulTheme};
|
use dialoguer::{FuzzySelect, Select, theme::ColorfulTheme};
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
|
|
@ -6,7 +6,7 @@ use tokio::{fs::File, io::AsyncWriteExt};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
models::{
|
models::{
|
||||||
config::{Config, Server},
|
config::{Config, Mods, Server},
|
||||||
fabric::FabricVersions,
|
fabric::FabricVersions,
|
||||||
vanilla::{VanillaVersionDetail, VanillaVersionType, VanillaVersions},
|
vanilla::{VanillaVersionDetail, VanillaVersionType, VanillaVersions},
|
||||||
},
|
},
|
||||||
|
|
@ -188,7 +188,7 @@ impl LoaderDownloader for VanillaDownloader {
|
||||||
loader: Self::name(),
|
loader: Self::name(),
|
||||||
loader_version: None,
|
loader_version: None,
|
||||||
},
|
},
|
||||||
mods: HashMap::new(),
|
mods: Mods {},
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
|
|
@ -302,7 +302,7 @@ impl LoaderDownloader for FabricDownloader {
|
||||||
loader: Self::name(),
|
loader: Self::name(),
|
||||||
loader_version: create.loader_version.clone(),
|
loader_version: create.loader_version.clone(),
|
||||||
},
|
},
|
||||||
mods: HashMap::new(),
|
mods: Mods {},
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ impl Install {
|
||||||
if file_res.is_err() {
|
if file_res.is_err() {
|
||||||
return Err("current directory is not a mcsm project".into());
|
return Err("current directory is not a mcsm project".into());
|
||||||
}
|
}
|
||||||
let mut config: Config = toml::from_str(&file_res.unwrap())?;
|
let config: Config = toml::from_str(&file_res.unwrap())?;
|
||||||
|
|
||||||
if config.server.loader == "Vanilla" {
|
if config.server.loader == "Vanilla" {
|
||||||
return Err("cannot search for mods on Vanilla server".into());
|
return Err("cannot search for mods on Vanilla server".into());
|
||||||
|
|
@ -47,7 +47,7 @@ impl Install {
|
||||||
game_versions: format!(r#"["{}"]"#, config.server.version),
|
game_versions: format!(r#"["{}"]"#, config.server.version),
|
||||||
};
|
};
|
||||||
|
|
||||||
let res: Vec<InstallResult> = with_spinner(
|
let install_result: Vec<InstallResult> = with_spinner(
|
||||||
format!("fetching {}", mod_name).as_str(),
|
format!("fetching {}", mod_name).as_str(),
|
||||||
format!("fetched {}", mod_name).as_str(),
|
format!("fetched {}", mod_name).as_str(),
|
||||||
|| async {
|
|| async {
|
||||||
|
|
@ -62,9 +62,7 @@ impl Install {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let install_result = res.first().unwrap();
|
let file = install_result.first().unwrap().files.first().unwrap();
|
||||||
let file = &install_result.files.first().unwrap();
|
|
||||||
let version_number = &install_result.version_number;
|
|
||||||
with_progressbar(
|
with_progressbar(
|
||||||
format!("downloading {}", mod_name).as_str(),
|
format!("downloading {}", mod_name).as_str(),
|
||||||
format!("downloaded {}", mod_name).as_str(),
|
format!("downloaded {}", mod_name).as_str(),
|
||||||
|
|
@ -90,7 +88,7 @@ impl Install {
|
||||||
let verified = verify_sha512(&data, &file.hashes.sha512);
|
let verified = verify_sha512(&data, &file.hashes.sha512);
|
||||||
|
|
||||||
if !verified {
|
if !verified {
|
||||||
tokio::fs::remove_file(&file.filename).await?;
|
tokio::fs::remove_file("server.jar").await?;
|
||||||
return Err("sha1 verifaction failed for downloaded file".into());
|
return Err("sha1 verifaction failed for downloaded file".into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,8 +96,6 @@ impl Install {
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
config.mods.insert(mod_name.clone(), version_number.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
|
@ -107,13 +103,6 @@ impl Install {
|
||||||
dialoguer::console::style("✔").green()
|
dialoguer::console::style("✔").green()
|
||||||
);
|
);
|
||||||
|
|
||||||
with_spinner("saving to config", "saved to config", || async {
|
|
||||||
std::env::set_current_dir("..")?;
|
|
||||||
let config_str = toml::to_string(&config)?;
|
|
||||||
tokio::fs::write("mcsm.toml", config_str).await?;
|
|
||||||
Ok(())
|
|
||||||
}).await?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub server: Server,
|
pub server: Server,
|
||||||
pub mods: HashMap<String, String>,
|
pub mods: Mods,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
|
|
@ -14,3 +12,6 @@ pub struct Server {
|
||||||
pub loader: String,
|
pub loader: String,
|
||||||
pub loader_version: Option<String>,
|
pub loader_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Mods {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue