mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-27 20:34:03 +00:00
Fix crash if the TRAINING_MODPACK_ROOT path doesn't already exist (#606)
* Fix crash if the TRAINING_MODPACK_ROOT path doesn't already exist * rustfmt
This commit is contained in:
parent
00f2284397
commit
df6b3ec493
2 changed files with 9 additions and 2 deletions
|
@ -10,8 +10,10 @@ use serde_json::Value;
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref CURRENT_VERSION: Mutex<String> =
|
pub static ref CURRENT_VERSION: Mutex<String> = Mutex::new(match get_current_version() {
|
||||||
Mutex::new(get_current_version().expect("Could not find current modpack version!\n"));
|
Ok(v) => v,
|
||||||
|
Err(e) => panic!("Could not find current modpack version!: {}", e),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -64,6 +64,11 @@ impl TrainingModpackConfig {
|
||||||
if fs::metadata(TRAINING_MODPACK_TOML_PATH).is_ok() {
|
if fs::metadata(TRAINING_MODPACK_TOML_PATH).is_ok() {
|
||||||
Err(io::Error::from(io::ErrorKind::AlreadyExists).into())
|
Err(io::Error::from(io::ErrorKind::AlreadyExists).into())
|
||||||
} else {
|
} else {
|
||||||
|
if !fs::metadata(TRAINING_MODPACK_ROOT).is_ok() {
|
||||||
|
// Root path doesn't exist, create it before trying to make the file
|
||||||
|
println!("Creating directory...");
|
||||||
|
fs::create_dir_all(TRAINING_MODPACK_ROOT)?;
|
||||||
|
}
|
||||||
let default_config: TrainingModpackConfig = TrainingModpackConfig::new();
|
let default_config: TrainingModpackConfig = TrainingModpackConfig::new();
|
||||||
let contents = toml::to_string(&default_config)?;
|
let contents = toml::to_string(&default_config)?;
|
||||||
fs::write(TRAINING_MODPACK_TOML_PATH, contents)?;
|
fs::write(TRAINING_MODPACK_TOML_PATH, contents)?;
|
||||||
|
|
Loading…
Reference in a new issue