From 9c6c435b05bb9bfc336d100947860da17a1cce0e Mon Sep 17 00:00:00 2001 From: guinux Date: Tue, 8 Aug 2017 11:06:37 +0200 Subject: [PATCH] real update .files db in background --- src/system_daemon.vala | 4 ++-- src/transaction.vala | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/system_daemon.vala b/src/system_daemon.vala index 65559a5..7d199f9 100644 --- a/src/system_daemon.vala +++ b/src/system_daemon.vala @@ -141,8 +141,8 @@ namespace Pamac { (alpm_action) => { alpm_action.run (); }, - // only one thread created so alpm action will run one after one - 1, + // two threads at a time + 2, // no exclusive thread false ); diff --git a/src/transaction.vala b/src/transaction.vala index 0aee417..ac8431a 100644 --- a/src/transaction.vala +++ b/src/transaction.vala @@ -456,19 +456,24 @@ namespace Pamac { } public void start_refresh (bool force) { - string action = dgettext (null, "Synchronizing package databases") + "..."; - reset_progress_box (action); - connecting_system_daemon (); - connecting_dbus_signals (); - try { - system_daemon.refresh_finished.connect (on_refresh_finished); - system_daemon.start_refresh (force); - } catch (IOError e) { - stderr.printf ("IOError: %s\n", e.message); - system_daemon.refresh_finished.disconnect (on_refresh_finished); - success = false; - finish_transaction (); - } + check_authorization.begin ((obj, res) => { + bool authorized = check_authorization.end (res); + if (authorized) { + string action = dgettext (null, "Synchronizing package databases") + "..."; + reset_progress_box (action); + connecting_system_daemon (); + connecting_dbus_signals (); + try { + system_daemon.refresh_finished.connect (on_refresh_finished); + system_daemon.start_refresh (force); + } catch (IOError e) { + stderr.printf ("IOError: %s\n", e.message); + system_daemon.refresh_finished.disconnect (on_refresh_finished); + success = false; + finish_transaction (); + } + } + }); } public void refresh_handle () {