Add filtering for already installed dependencies
parent
d2f645e34f
commit
ad34e8bf8b
@ -1,112 +0,0 @@
|
|||||||
use std::env;
|
|
||||||
use std::path::Path;
|
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
use crate::{crash, internal::exit_code::AppExitCode};
|
|
||||||
|
|
||||||
pub fn init() {
|
|
||||||
let homedir = env::var("HOME").unwrap();
|
|
||||||
|
|
||||||
if !Path::new(&format!("{}/.local/share/ame", homedir)).exists() {
|
|
||||||
let r = std::fs::create_dir_all(format!("{}/.local/share/ame", homedir));
|
|
||||||
match r {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!("Created path: {}/.local/share/ame", homedir);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't create path: {}/.local/share/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !Path::new(&format!("{}/.cache/ame/", homedir)).exists() {
|
|
||||||
let r = std::fs::create_dir_all(format!("{}/.cache/ame", homedir));
|
|
||||||
match r {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!("Created path: {}/.cache/ame", homedir);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't create path: {}/.cache/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let r = std::fs::remove_dir_all(format!("{}/.cache/ame", homedir));
|
|
||||||
match r {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!("Removing cache: {}/.cache/ame", homedir);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't remove path: {}/.cache/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let r2 = std::fs::create_dir_all(format!("{}/.cache/ame", homedir));
|
|
||||||
match r2 {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!("Created path: {}/.cache/ame", homedir);
|
|
||||||
}
|
|
||||||
Err(e2) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't create path: {}/.cache/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e2,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let r = Command::new("chmod")
|
|
||||||
.arg("-R")
|
|
||||||
.arg("770")
|
|
||||||
.arg(format!("{}/.cache/ame", homedir))
|
|
||||||
.status();
|
|
||||||
match r {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!("Set correct permissions for path: {}/.cache/ame", homedir);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't set permissions for path: {}/.cache/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let r = Command::new("chmod")
|
|
||||||
.arg("-R")
|
|
||||||
.arg("770")
|
|
||||||
.arg(format!("{}/.local/share/ame", homedir))
|
|
||||||
.status();
|
|
||||||
match r {
|
|
||||||
Ok(_) => {
|
|
||||||
tracing::debug!(
|
|
||||||
"Set correct permissions for path: {}/.local/share/ame",
|
|
||||||
homedir
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
crash!(
|
|
||||||
AppExitCode::FailedCreatingPaths,
|
|
||||||
"Couldn't set permissions for path: {}/.local/share/ame: {}",
|
|
||||||
homedir,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in New Issue