moved cachedir removing code to init()

i18n
jan Michal 2 years ago
parent 976c833d01
commit 8b6fabad74
No known key found for this signature in database
GPG Key ID: CB521D73AA05EBF2

@ -44,5 +44,34 @@ pub fn init(options: Options) {
);
}
}
} else {
let r = std::fs::remove_dir_all(format!("{}/.cache/ame", homedir));
match r {
Ok(_) => {
if verbosity >= 1 {
log(format!("Removing cache: {}/.cache/ame", homedir));
}
}
Err(e) => {
crash(
format!("Couldn't remove path: {}/.cache/ame: {}", homedir, e),
4,
);
}
}
let r2 = std::fs::create_dir_all(format!("{}/.cache/ame", homedir));
match r2 {
Ok(_) => {
if verbosity >= 1 {
log(format!("Created path: {}/.cache/ame", homedir));
}
}
Err(e2) => {
crash(
format!("Couldn't create path: {}/.cache/ame: {}", homedir, e2),
4,
);
}
}
}
}

@ -1,6 +1,5 @@
use std::path::Path;
use std::process::{exit, Command};
use std::{env, fs, io};
use std::{env, io};
use clap::{App, AppSettings, Arg, ArgMatches, ArgSettings, Shell, SubCommand};
@ -22,14 +21,6 @@ fn main() {
crash("Running amethyst as root is disallowed as it can lead to system breakage. Instead, amethyst will prompt you when it needs superuser permissions".to_string(), 1);
}
let home = env::var("HOME").unwrap();
if !Path::exists(format!("{}/.cache/ame/", home).as_ref()) {
fs::create_dir_all(format!("{}/.cache/ame/", home)).unwrap();
} else {
fs::remove_dir_all(format!("{}/.cache/ame", home)).unwrap();
fs::create_dir_all(format!("{}/.cache/ame/", home)).unwrap();
}
fn build_app() -> App<'static, 'static> {
let app = App::new("Amethyst")
.version(env!("CARGO_PKG_VERSION"))

Loading…
Cancel
Save