From ec988c33d08bf270c68ff056a61a2fbc478ae01a Mon Sep 17 00:00:00 2001 From: guinux Date: Sun, 23 Sep 2018 15:00:41 +0200 Subject: [PATCH] keep authoriztion even after a long build --- src/alpm_utils.vala | 4 ++-- src/system_daemon.vala | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/alpm_utils.vala b/src/alpm_utils.vala index 18e0504..20a725b 100644 --- a/src/alpm_utils.vala +++ b/src/alpm_utils.vala @@ -1401,7 +1401,7 @@ namespace Pamac { } } - internal void compute_aur_build_list (string[] aur_list) { + internal void compute_aur_build_list () { try { Process.spawn_command_line_sync ("mkdir -p %s".printf (aurdb_path)); } catch (SpawnError e) { @@ -1409,7 +1409,7 @@ namespace Pamac { } aur_desc_list.remove_all (); already_checked_aur_dep.remove_all (); - check_aur_dep_list (aur_list); + check_aur_dep_list (to_build); } void check_aur_dep_list (string[] pkgnames) { diff --git a/src/system_daemon.vala b/src/system_daemon.vala index d7e9a39..84efd39 100644 --- a/src/system_daemon.vala +++ b/src/system_daemon.vala @@ -44,6 +44,7 @@ namespace Pamac { private string mirrorlist_country; private ThreadPool thread_pool; private BusName lock_id; + private bool authorized; private GLib.File lockfile; public signal void emit_event (uint primary_event, uint secondary_event, string[] details); @@ -68,6 +69,7 @@ namespace Pamac { public SystemDaemon () { lock_id = new BusName (""); + authorized = false; // alpm_utils global variable declared in alpm_utils.vala alpm_utils = new AlpmUtils (); lockfile = GLib.File.new_for_path (alpm_utils.alpm_handle.lockfile); @@ -234,6 +236,7 @@ namespace Pamac { public bool unlock (GLib.BusName sender) throws Error { if (lock_id == sender) { lock_id = new BusName (""); + authorized = false; return true; } return false; @@ -243,9 +246,12 @@ namespace Pamac { if (lock_id != sender) { return false; } - bool authorized = false; + if (authorized) { + return true; + } + authorized = false; try { - Polkit.Authority authority = Polkit.Authority.get_sync (); + Polkit.Authority authority = yield Polkit.Authority.get_async (); Polkit.Subject subject = new Polkit.SystemBusName (sender); var result = yield authority.check_authorization ( subject, @@ -275,7 +281,7 @@ namespace Pamac { check_authorization.begin (sender, (obj, res) => { var pamac_config = new Config ("/etc/pamac.conf"); bool authorized = check_authorization.end (res); - if (authorized ) { + if (authorized) { pamac_config.write (new_pamac_conf); pamac_config.reload (); } @@ -295,7 +301,7 @@ namespace Pamac { public void start_write_alpm_config (HashTable new_alpm_conf, GLib.BusName sender) throws Error { check_authorization.begin (sender, (obj, res) => { bool authorized = check_authorization.end (res); - if (authorized ) { + if (authorized) { this.new_alpm_conf = new_alpm_conf; try { thread_pool.add (new AlpmAction (write_alpm_config)); @@ -495,8 +501,8 @@ namespace Pamac { private void launch_prepare_thread () { if (alpm_utils.to_build.length != 0) { - alpm_utils.compute_aur_build_list (alpm_utils.to_build); try { + thread_pool.add (new AlpmAction (alpm_utils.compute_aur_build_list)); thread_pool.add (new AlpmAction (alpm_utils.build_prepare)); } catch (ThreadError e) { stderr.printf ("Thread Error %s\n", e.message); -- GitLab