fix apt double run

This commit is contained in:
Ward from fusion-voyager-3 2024-10-01 23:53:39 +03:00
parent 0a4ff5d59b
commit d24efe2f8c
4 changed files with 33 additions and 5 deletions

View File

@ -19,7 +19,8 @@ use tokio::runtime::Runtime;
pub fn add_dialog_fn( pub fn add_dialog_fn(
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
reload_action: &gio::SimpleAction reload_action: &gio::SimpleAction,
apt_retry_signal_action: &gio::SimpleAction,
) )
{ {
let unofficial_source_add_dialog_child_box = Box::builder() let unofficial_source_add_dialog_child_box = Box::builder()
@ -283,6 +284,7 @@ pub fn add_dialog_fn(
unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup); unofficial_source_add_dialog_child_box.append(&unofficial_source_add_signed_prefrencesgroup);
let reload_action_clone0 = reload_action.clone(); let reload_action_clone0 = reload_action.clone();
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
unofficial_source_add_dialog.clone() unofficial_source_add_dialog.clone()
.choose(None::<&gio::Cancellable>, move |choice| { .choose(None::<&gio::Cancellable>, move |choice| {
@ -326,6 +328,8 @@ pub fn add_dialog_fn(
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move_with_wget", &repo_file_name, &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)).run() { match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move_with_wget", &repo_file_name, &unofficial_source_add_signed_entry.text().to_string(), &format!("/etc/apt/keyrings/{}.gpg.key", &repo_file_name)).run() {
Ok(_) => { Ok(_) => {
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
Err(e) => { Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder() let apt_src_create_error_dialog = adw::MessageDialog::builder()
@ -338,6 +342,7 @@ pub fn add_dialog_fn(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
} }
} }
@ -359,6 +364,7 @@ pub fn add_dialog_fn(
match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() { match duct::cmd!("pkexec", "/usr/lib/pika/pikman-update-manager/scripts/modify_repo.sh", "deb822_move", repo_file_name).run() {
Ok(_) => { Ok(_) => {
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
Err(e) => { Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder() let apt_src_create_error_dialog = adw::MessageDialog::builder()
@ -371,6 +377,7 @@ pub fn add_dialog_fn(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
} }
} }
@ -385,6 +392,7 @@ pub fn add_dialog_fn(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
} }
} }

View File

@ -22,6 +22,7 @@ pub fn deb822_edit_dialog_fn(
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
deb822_repo: &Deb822Repository, deb822_repo: &Deb822Repository,
reload_action: &gio::SimpleAction, reload_action: &gio::SimpleAction,
apt_retry_signal_action: &SimpleAction,
) { ) {
let repofile_path = Path::new(&deb822_repo.filepath); let repofile_path = Path::new(&deb822_repo.filepath);
let repo_file_name = repofile_path let repo_file_name = repofile_path
@ -342,6 +343,8 @@ pub fn deb822_edit_dialog_fn(
let deb822_repo_clone0 = deb822_repo.clone(); let deb822_repo_clone0 = deb822_repo.clone();
let reload_action_clone0 = reload_action.clone(); let reload_action_clone0 = reload_action.clone();
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
unofficial_source_add_dialog.clone() unofficial_source_add_dialog.clone()
.choose(None::<&gio::Cancellable>, move |choice| { .choose(None::<&gio::Cancellable>, move |choice| {
@ -395,6 +398,7 @@ pub fn deb822_edit_dialog_fn(
} }
} }
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
Err(e) => { Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder() let apt_src_create_error_dialog = adw::MessageDialog::builder()
@ -407,6 +411,7 @@ pub fn deb822_edit_dialog_fn(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
} }
} }

View File

@ -22,6 +22,7 @@ pub fn legacy_edit_dialog_fn(
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
legacy_repo: &LegacyAptSource, legacy_repo: &LegacyAptSource,
reload_action: &gio::SimpleAction, reload_action: &gio::SimpleAction,
apt_retry_signal_action: &SimpleAction,
) { ) {
let repofile_path = Path::new(&legacy_repo.filepath); let repofile_path = Path::new(&legacy_repo.filepath);
let repo_file_name = repofile_path let repo_file_name = repofile_path
@ -217,6 +218,7 @@ pub fn legacy_edit_dialog_fn(
let legacy_repo_clone0 = legacy_repo.clone(); let legacy_repo_clone0 = legacy_repo.clone();
let reload_action_clone0 = reload_action.clone(); let reload_action_clone0 = reload_action.clone();
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
unofficial_source_add_dialog.clone() unofficial_source_add_dialog.clone()
.choose(None::<&gio::Cancellable>, move |choice| { .choose(None::<&gio::Cancellable>, move |choice| {
@ -251,6 +253,7 @@ pub fn legacy_edit_dialog_fn(
} }
} }
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
Err(e) => { Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder() let apt_src_create_error_dialog = adw::MessageDialog::builder()
@ -263,6 +266,7 @@ pub fn legacy_edit_dialog_fn(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
reload_action_clone0.activate(None); reload_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None);
} }
} }
} }

View File

@ -29,8 +29,9 @@ enum AptSourceConfig {
pub fn apt_manage_page( pub fn apt_manage_page(
window: adw::ApplicationWindow, window: adw::ApplicationWindow,
retry_signal_action: &SimpleAction, apt_retry_signal_action: &SimpleAction,
) -> gtk::Box { ) -> gtk::Box {
let retry_signal_action = gio::SimpleAction::new("apt_manage_retry", None);
let deb822_sources = Deb822Repository::get_deb822_sources().unwrap(); let deb822_sources = Deb822Repository::get_deb822_sources().unwrap();
@ -395,12 +396,15 @@ pub fn apt_manage_page(
window, window,
#[strong] #[strong]
retry_signal_action, retry_signal_action,
#[strong]
apt_retry_signal_action,
move move
|_| |_|
{ {
add_dialog::add_dialog_fn( add_dialog::add_dialog_fn(
window.clone(), window.clone(),
&retry_signal_action &retry_signal_action,
&apt_retry_signal_action
); );
} }
) )
@ -413,6 +417,8 @@ pub fn apt_manage_page(
unofficial_sources_selection_model_rc, unofficial_sources_selection_model_rc,
#[strong] #[strong]
retry_signal_action, retry_signal_action,
#[strong]
apt_retry_signal_action,
move move
|_| |_|
{ {
@ -422,10 +428,10 @@ pub fn apt_manage_page(
let apt_src: Ref<AptSourceConfig> = item.borrow(); let apt_src: Ref<AptSourceConfig> = item.borrow();
match apt_src.deref() { match apt_src.deref() {
AptSourceConfig::DEB822(src) => { AptSourceConfig::DEB822(src) => {
deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &retry_signal_action); deb822_edit_dialog::deb822_edit_dialog_fn(window.clone(), src, &retry_signal_action, &apt_retry_signal_action);
} }
AptSourceConfig::Legacy(list) => { AptSourceConfig::Legacy(list) => {
legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action) legacy_edit_dialog::legacy_edit_dialog_fn(window.clone(), list, &retry_signal_action, &apt_retry_signal_action)
} }
}; };
@ -440,6 +446,8 @@ pub fn apt_manage_page(
unofficial_sources_selection_model_rc, unofficial_sources_selection_model_rc,
#[strong] #[strong]
retry_signal_action, retry_signal_action,
#[strong]
apt_retry_signal_action,
move move
|_| |_|
{ {
@ -475,6 +483,7 @@ pub fn apt_manage_page(
); );
apt_src_remove_warning_dialog.set_response_appearance("apt_src_remove_warning_dialog_ok", adw::ResponseAppearance::Destructive); apt_src_remove_warning_dialog.set_response_appearance("apt_src_remove_warning_dialog_ok", adw::ResponseAppearance::Destructive);
let retry_signal_action_clone0 = retry_signal_action.clone(); let retry_signal_action_clone0 = retry_signal_action.clone();
let apt_retry_signal_action_clone0 = apt_retry_signal_action.clone();
apt_src_remove_warning_dialog.clone() apt_src_remove_warning_dialog.clone()
.choose(None::<&gio::Cancellable>, move |choice| { .choose(None::<&gio::Cancellable>, move |choice| {
match choice.as_str() { match choice.as_str() {
@ -482,6 +491,7 @@ pub fn apt_manage_page(
match command.run() { match command.run() {
Ok(_) => { Ok(_) => {
retry_signal_action_clone0.activate(None); retry_signal_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None)
} }
Err(e) => { Err(e) => {
let apt_src_create_error_dialog = adw::MessageDialog::builder() let apt_src_create_error_dialog = adw::MessageDialog::builder()
@ -494,6 +504,7 @@ pub fn apt_manage_page(
); );
apt_src_create_error_dialog.present(); apt_src_create_error_dialog.present();
retry_signal_action_clone0.activate(None); retry_signal_action_clone0.activate(None);
apt_retry_signal_action_clone0.activate(None)
} }
} }
} }