fix full select
This commit is contained in:
parent
0c03d60203
commit
c055c23e08
@ -10,24 +10,32 @@ fn main() {
|
|||||||
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
let percent_socket_path = "/tmp/pika_apt_upgrade_percent.sock";
|
||||||
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
let status_socket_path = "/tmp/pika_apt_upgrade_status.sock";
|
||||||
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
let json_file_path = "/tmp/pika-apt-exclusions.json";
|
||||||
let mut excluded_updates_vec = Vec::new();
|
let mut excluded_updates_vec: Vec<String> = Vec::new();
|
||||||
|
|
||||||
let json: serde_json::Value = serde_json::from_str(
|
if std::path::Path::new(json_file_path).exists() {
|
||||||
&std::fs::read_to_string(json_file_path).expect("Unable to read file"),
|
let data = std::fs::read_to_string(json_file_path).expect("Unable to read file");
|
||||||
)
|
let json: serde_json::Value = serde_json::from_str(&data).expect("JSON was not well-formatted");
|
||||||
.expect("JSON was not well-formatted");
|
|
||||||
|
|
||||||
if let serde_json::Value::Array(exclusions) = &json["exclusions"] {
|
if let serde_json::Value::Array(exclusions) = &json["exclusions"] {
|
||||||
for exclusion in exclusions {
|
for exclusion in exclusions {
|
||||||
excluded_updates_vec.push(exclusion["package"].as_str().unwrap());
|
match exclusion["package"].as_str() {
|
||||||
|
Some(v) => {
|
||||||
|
excluded_updates_vec.push(v.to_owned());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let apt_cache = new_cache!().unwrap();
|
let apt_cache = new_cache!().unwrap();
|
||||||
let apt_upgrade_cache = new_cache!().unwrap();
|
|
||||||
|
|
||||||
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
apt_cache.upgrade(Upgrade::FullUpgrade).unwrap();
|
||||||
|
|
||||||
|
let apt_upgrade_cache = if excluded_updates_vec.is_empty() {
|
||||||
|
apt_cache
|
||||||
|
} else {
|
||||||
|
let apt_upgrade_cache = new_cache!().unwrap();
|
||||||
for change in apt_cache.get_changes(false) {
|
for change in apt_cache.get_changes(false) {
|
||||||
if !excluded_updates_vec
|
if !excluded_updates_vec
|
||||||
.iter()
|
.iter()
|
||||||
@ -42,6 +50,8 @@ fn main() {
|
|||||||
pkg.protect();
|
pkg.protect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
apt_upgrade_cache
|
||||||
|
};
|
||||||
|
|
||||||
apt_upgrade_cache.resolve(true).unwrap();
|
apt_upgrade_cache.resolve(true).unwrap();
|
||||||
|
|
||||||
|
@ -209,7 +209,10 @@ pub fn apt_update_page(
|
|||||||
// The main loop executes the asynchronous block
|
// The main loop executes the asynchronous block
|
||||||
update_percent_server_context.spawn_local(clone!(#[weak] apt_update_dialog_progress_bar, async move {
|
update_percent_server_context.spawn_local(clone!(#[weak] apt_update_dialog_progress_bar, async move {
|
||||||
while let Ok(state) = update_percent_receiver.recv().await {
|
while let Ok(state) = update_percent_receiver.recv().await {
|
||||||
apt_update_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
match state.parse::<f64>() {
|
||||||
|
Ok(p) => apt_update_dialog_progress_bar.set_fraction(p/100.0),
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -471,7 +471,10 @@ fn apt_full_upgrade_from_socket(
|
|||||||
match state.as_ref() {
|
match state.as_ref() {
|
||||||
"FN_OVERRIDE_SUCCESSFUL" => {}
|
"FN_OVERRIDE_SUCCESSFUL" => {}
|
||||||
_ => {
|
_ => {
|
||||||
apt_upgrade_dialog_progress_bar.set_fraction(state.parse::<f64>().unwrap()/100.0)
|
match state.parse::<f64>() {
|
||||||
|
Ok(p) => apt_upgrade_dialog_progress_bar.set_fraction(p/100.0),
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ use std::thread;
|
|||||||
|
|
||||||
pub fn build_ui(app: &Application) {
|
pub fn build_ui(app: &Application) {
|
||||||
// setup glib
|
// setup glib
|
||||||
glib::set_prgname(Some(t!("app_name").to_string()));
|
glib::set_prgname(Some(t!("application_name").to_string()));
|
||||||
glib::set_application_name(&t!("app_name").to_string());
|
glib::set_application_name(&t!("application_name").to_string());
|
||||||
|
|
||||||
let internet_connected = Rc::new(RefCell::new(false));
|
let internet_connected = Rc::new(RefCell::new(false));
|
||||||
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
let (internet_loop_sender, internet_loop_receiver) = async_channel::unbounded();
|
||||||
|
Loading…
Reference in New Issue
Block a user