move from gio thread to std thread to fix async terminal logging

This commit is contained in:
Ward from fusion-voyager-3 2024-03-16 02:23:17 +03:00
parent c9441b023d
commit 2e89ee7211
2 changed files with 18 additions and 12 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
pika-welcome (5.0.0-100pika7) pikauwu; urgency=low pika-welcome (5.0.0-100pika8) pikauwu; urgency=low
* Temp internet fix * Temp internet fix

View File

@ -156,7 +156,6 @@ pub fn recommended_addons_page(
gio::spawn_blocking( gio::spawn_blocking(
clone!(@strong checkpkg_status_loop_sender, @strong entry_checkpkg => move || loop { clone!(@strong checkpkg_status_loop_sender, @strong entry_checkpkg => move || loop {
thread::sleep(time::Duration::from_secs(6));
let checkpkg_command = Command::new("dpkg") let checkpkg_command = Command::new("dpkg")
.arg("-s") .arg("-s")
.arg(&entry_checkpkg) .arg(&entry_checkpkg)
@ -167,6 +166,7 @@ pub fn recommended_addons_page(
} else { } else {
checkpkg_status_loop_sender.send_blocking(false).expect("The channel needs to be open."); checkpkg_status_loop_sender.send_blocking(false).expect("The channel needs to be open.");
} }
thread::sleep(time::Duration::from_secs(6));
}), }),
); );
@ -275,33 +275,39 @@ pub fn recommended_addons_page(
recommended_addons_command_dialog.set_body(""); recommended_addons_command_dialog.set_body("");
recommended_addons_command_dialog.present(); recommended_addons_command_dialog.present();
if &entry_row_button.widget_name() == "true" { if &entry_row_button.widget_name() == "true" {
gio::spawn_blocking(clone!(@strong log_loop_sender, @strong log_status_loop_sender, @strong entry_packages => move || { let log_status_loop_sender_clone = log_status_loop_sender.clone();
let command = run_addon_command(log_loop_sender, "remove", &entry_packages); let log_loop_sender_clone= log_loop_sender.clone();
let entry_packages_clone= entry_packages.clone();
std::thread::spawn(move || {
let command = run_addon_command(log_loop_sender_clone, "remove", &entry_packages_clone);
match command { match command {
Ok(_) => { Ok(_) => {
println!("Status: Addon Command Successful"); println!("Status: Addon Command Successful");
log_status_loop_sender.send_blocking(true).expect("The channel needs to be open."); log_status_loop_sender_clone.send_blocking(true).expect("The channel needs to be open.");
} }
Err(_) => { Err(_) => {
println!("Status: Addon Command Failed"); println!("Status: Addon Command Failed");
log_status_loop_sender.send_blocking(false).expect("The channel needs to be open."); log_status_loop_sender_clone.send_blocking(false).expect("The channel needs to be open.");
} }
} }
})); });
} else { } else {
gio::spawn_blocking(clone!(@strong log_loop_sender, @strong log_status_loop_sender, @strong entry_packages => move || { let log_status_loop_sender_clone = log_status_loop_sender.clone();
let command = run_addon_command(log_loop_sender, "install", &entry_packages); let log_loop_sender_clone= log_loop_sender.clone();
let entry_packages_clone= entry_packages.clone();
std::thread::spawn(move || {
let command = run_addon_command(log_loop_sender_clone, "install", &entry_packages_clone);
match command { match command {
Ok(_) => { Ok(_) => {
println!("Status: Addon Command Successful"); println!("Status: Addon Command Successful");
log_status_loop_sender.send_blocking(true).expect("The channel needs to be open."); log_status_loop_sender_clone.send_blocking(true).expect("The channel needs to be open.");
} }
Err(_) => { Err(_) => {
println!("Status: Addon Command Failed"); println!("Status: Addon Command Failed");
log_status_loop_sender.send_blocking(false).expect("The channel needs to be open."); log_status_loop_sender_clone.send_blocking(false).expect("The channel needs to be open.");
} }
} }
})); });
} }
})); }));