|
|
@ -8,10 +8,10 @@ pub fn stat_create_database() {
|
|
|
|
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
|
|
|
|
let _cdar = fs::create_dir_all(format!("/{}/.local/ame/",homepath));
|
|
|
|
match _cdar {
|
|
|
|
match _cdar {
|
|
|
|
Ok(_) => {
|
|
|
|
Ok(_) => {
|
|
|
|
inf(format!("Created path for database (previously missing)"))
|
|
|
|
inf("Created path for database (previously missing)".to_string());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(_) => {
|
|
|
|
Err(_) => {
|
|
|
|
err_unrec(format!("Couldn't create path for database (~/.local/rhare/ame)"))
|
|
|
|
err_unrec("Couldn't create path for database (~/.local/share/ame)".to_string())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -24,6 +24,29 @@ pub fn stat_create_database() {
|
|
|
|
.unwrap();
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn stat_dump_dat() -> Vec<String> {
|
|
|
|
|
|
|
|
let homepath = env::var("HOME").unwrap();
|
|
|
|
|
|
|
|
let file = format!("{}/.local/share/ame/aur_pkgs.db", env::var("HOME").unwrap());
|
|
|
|
|
|
|
|
let connection = sqlite::open(file).unwrap();
|
|
|
|
|
|
|
|
let mut dat_pkgs = Vec::new();
|
|
|
|
|
|
|
|
let result = connection
|
|
|
|
|
|
|
|
.iterate("SELECT name FROM static_pkgs", |pairs| {
|
|
|
|
|
|
|
|
for &(column, value) in pairs.iter() {
|
|
|
|
|
|
|
|
dat_pkgs.push(value.unwrap().to_string());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
match result {
|
|
|
|
|
|
|
|
Ok(_) => {
|
|
|
|
|
|
|
|
//nf("Dumped static packages".to_string());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Err(_) => {
|
|
|
|
|
|
|
|
err_unrec("Couldn't dump packages from database".to_string())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return dat_pkgs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn stat_get_value(pkg: &str, sear_value: &str) -> bool {
|
|
|
|
pub fn stat_get_value(pkg: &str, sear_value: &str) -> bool {
|
|
|
|
let file = format!("{}/.local/share/ame/aur_pkgs.db", env::var("HOME").unwrap());
|
|
|
|
let file = format!("{}/.local/share/ame/aur_pkgs.db", env::var("HOME").unwrap());
|
|
|
|
let connection = sqlite::open(file).unwrap();
|
|
|
|
let connection = sqlite::open(file).unwrap();
|
|
|
@ -42,11 +65,7 @@ pub fn stat_get_value(pkg: &str, sear_value: &str) -> bool {
|
|
|
|
Ok(_) => {},
|
|
|
|
Ok(_) => {},
|
|
|
|
Err(_) => err_unrec("Couldn't get value from database".to_string()),
|
|
|
|
Err(_) => err_unrec("Couldn't get value from database".to_string()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if return_val == true {
|
|
|
|
return return_val == true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"update" => {
|
|
|
|
"update" => {
|
|
|
|
let result = connection.iterate(format!("SELECT pin FROM static_pkgs WHERE name = \"{}\";",&pkg), |pairs| {
|
|
|
|
let result = connection.iterate(format!("SELECT pin FROM static_pkgs WHERE name = \"{}\";",&pkg), |pairs| {
|
|
|
@ -60,11 +79,7 @@ pub fn stat_get_value(pkg: &str, sear_value: &str) -> bool {
|
|
|
|
Ok(_) => {},
|
|
|
|
Ok(_) => {},
|
|
|
|
Err(_) => err_unrec("Couldn't get value from database".to_string()),
|
|
|
|
Err(_) => err_unrec("Couldn't get value from database".to_string()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if return_val == true {
|
|
|
|
return return_val == true
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
_ => {
|
|
|
|
return_val = false
|
|
|
|
return_val = false
|
|
|
@ -76,7 +91,7 @@ pub fn stat_get_value(pkg: &str, sear_value: &str) -> bool {
|
|
|
|
pub fn stat_rem_pkg(static_pkgs: &Vec<String>) {
|
|
|
|
pub fn stat_rem_pkg(static_pkgs: &Vec<String>) {
|
|
|
|
let file = format!("{}/.local/share/ame/aur_pkgs.db", env::var("HOME").unwrap());
|
|
|
|
let file = format!("{}/.local/share/ame/aur_pkgs.db", env::var("HOME").unwrap());
|
|
|
|
let connection = sqlite::open(file).unwrap();
|
|
|
|
let connection = sqlite::open(file).unwrap();
|
|
|
|
|
|
|
|
print!("{:?}",static_pkgs);
|
|
|
|
for i in static_pkgs {
|
|
|
|
for i in static_pkgs {
|
|
|
|
let result = connection.execute(
|
|
|
|
let result = connection.execute(
|
|
|
|
format!("
|
|
|
|
format!("
|
|
|
@ -88,7 +103,7 @@ pub fn stat_rem_pkg(static_pkgs: &Vec<String>) {
|
|
|
|
inf(format!("Removed {} from database", i))
|
|
|
|
inf(format!("Removed {} from database", i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(_) => {
|
|
|
|
Err(_) => {
|
|
|
|
err_unrec(format!("Couldn't remove {} from database", i))
|
|
|
|
err_unrec(format!("Couldn't remove {} from database (static packages table)", i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|