improve transaction cancellation

This commit is contained in:
guinux 2016-11-02 14:23:52 +01:00
parent 1315bb265e
commit 70fe12c83c
3 changed files with 23 additions and 3 deletions

View File

@ -41,5 +41,5 @@ manager_resources.c: $(MANAGER_GRESOURCE_FILE) $(MANAGER_RESOURCES_FILES)
updater_resources.c: $(UPDATER_GRESOURCE_FILE) $(UPDATER_RESOURCES_FILES) updater_resources.c: $(UPDATER_GRESOURCE_FILE) $(UPDATER_RESOURCES_FILES)
glib-compile-resources $(UPDATER_GRESOURCE_FILE) --target=updater_resources.c --generate-source glib-compile-resources $(UPDATER_GRESOURCE_FILE) --target=updater_resources.c --generate-source
installer_resources.c: $(INSTALLER_GRESOURCE_FILE) $(INSTALLER_RESOURCES_FILE) installer_resources.c: $(INSTALLER_GRESOURCE_FILE) $(INSTALLER_RESOURCES_FILES)
glib-compile-resources $(INSTALLER_GRESOURCE_FILE) --target=installer_resources.c --generate-source glib-compile-resources $(INSTALLER_GRESOURCE_FILE) --target=installer_resources.c --generate-source

View File

@ -398,6 +398,11 @@ namespace Pamac {
emit_event (0, 0, {}); emit_event (0, 0, {});
databases_lock_mutex.lock (); databases_lock_mutex.lock ();
} }
if (cancellable.is_cancelled ()) {
databases_lock_mutex.unlock ();
cancellable.reset ();
return;
}
write_log_file ("synchronizing package lists"); write_log_file ("synchronizing package lists");
current_error = ErrorInfos (); current_error = ErrorInfos ();
int force = (force_refresh) ? 1 : 0; int force = (force_refresh) ? 1 : 0;
@ -1335,6 +1340,11 @@ namespace Pamac {
emit_event (0, 0, {}); emit_event (0, 0, {});
databases_lock_mutex.lock (); databases_lock_mutex.lock ();
} }
if (cancellable.is_cancelled ()) {
databases_lock_mutex.unlock ();
cancellable.reset ();
return false;
}
current_error = ErrorInfos (); current_error = ErrorInfos ();
cancellable.reset (); cancellable.reset ();
if (alpm_handle.trans_init (flags) == -1) { if (alpm_handle.trans_init (flags) == -1) {
@ -1353,7 +1363,11 @@ namespace Pamac {
private void sysupgrade_prepare () { private void sysupgrade_prepare () {
current_error = ErrorInfos (); current_error = ErrorInfos ();
if (!trans_init (0)) { if (!trans_init (0)) {
trans_prepare_finished (false); if (cancellable.is_cancelled ()) {
trans_prepare_finished (true);
} else {
trans_prepare_finished (false);
}
return; return;
} }
add_ignorepkgs (); add_ignorepkgs ();
@ -1610,7 +1624,11 @@ namespace Pamac {
trans_prepare_finished (false); trans_prepare_finished (false);
} }
} else { } else {
trans_prepare_finished (false); if (cancellable.is_cancelled ()) {
trans_prepare_finished (true);
} else {
trans_prepare_finished (false);
}
} }
} }

View File

@ -997,6 +997,7 @@ namespace Pamac {
action = dgettext (null, "Checking dependencies") + "..."; action = dgettext (null, "Checking dependencies") + "...";
break; break;
case 3: //Alpm.Event.Type.FILECONFLICTS_START case 3: //Alpm.Event.Type.FILECONFLICTS_START
start_transaction ();
action = dgettext (null, "Checking file conflicts") + "..."; action = dgettext (null, "Checking file conflicts") + "...";
break; break;
case 5: //Alpm.Event.Type.RESOLVEDEPS_START case 5: //Alpm.Event.Type.RESOLVEDEPS_START
@ -1105,6 +1106,7 @@ namespace Pamac {
case 41: //Alpm.Event.Type.HOOK_START case 41: //Alpm.Event.Type.HOOK_START
switch (secondary_event) { switch (secondary_event) {
case 1: //Alpm.HookWhen.PRE_TRANSACTION case 1: //Alpm.HookWhen.PRE_TRANSACTION
start_transaction ();
action = dgettext (null, "Running pre-transaction hooks") + "..."; action = dgettext (null, "Running pre-transaction hooks") + "...";
break; break;
case 2: //Alpm.HookWhen.POST_TRANSACTION case 2: //Alpm.HookWhen.POST_TRANSACTION