forked from cromer/pamac-classic
some daemon fixes
This commit is contained in:
parent
99e72e5867
commit
af7912eccb
@ -102,6 +102,8 @@ namespace Pamac {
|
|||||||
public int? choosen_provider;
|
public int? choosen_provider;
|
||||||
private bool force_refresh;
|
private bool force_refresh;
|
||||||
private bool enable_downgrade;
|
private bool enable_downgrade;
|
||||||
|
private bool check_aur_updates;
|
||||||
|
private HashTable<string,Variant> new_alpm_conf;
|
||||||
private Alpm.TransFlag flags;
|
private Alpm.TransFlag flags;
|
||||||
private string[] to_install;
|
private string[] to_install;
|
||||||
private string[] to_remove;
|
private string[] to_remove;
|
||||||
@ -318,15 +320,28 @@ namespace Pamac {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf, GLib.BusName sender) {
|
private void write_alpm_config () {
|
||||||
|
alpm_config.write (new_alpm_conf);
|
||||||
|
alpm_config.reload ();
|
||||||
|
databases_lock_mutex.lock ();
|
||||||
|
refresh_handle ();
|
||||||
|
databases_lock_mutex.unlock ();
|
||||||
|
write_alpm_config_finished ((alpm_handle.checkspace == 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start_write_alpm_config (HashTable<string,Variant> new_alpm_conf_, GLib.BusName sender) {
|
||||||
check_authorization.begin (sender, (obj, res) => {
|
check_authorization.begin (sender, (obj, res) => {
|
||||||
bool authorized = check_authorization.end (res);
|
bool authorized = check_authorization.end (res);
|
||||||
if (authorized ) {
|
if (authorized ) {
|
||||||
alpm_config.write (new_alpm_conf);
|
new_alpm_conf = new_alpm_conf_;
|
||||||
alpm_config.reload ();
|
try {
|
||||||
refresh_handle ();
|
thread_pool.add (new AlpmAction (write_alpm_config));
|
||||||
|
} catch (ThreadError e) {
|
||||||
|
stderr.printf ("Thread Error %s\n", e.message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
write_alpm_config_finished ((alpm_handle.checkspace == 1));
|
||||||
}
|
}
|
||||||
write_alpm_config_finished ((alpm_handle.checkspace == 1));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +359,9 @@ namespace Pamac {
|
|||||||
stderr.printf ("Error: %s\n", e.message);
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
}
|
}
|
||||||
alpm_config.reload ();
|
alpm_config.reload ();
|
||||||
|
databases_lock_mutex.lock ();
|
||||||
refresh_handle ();
|
refresh_handle ();
|
||||||
|
databases_lock_mutex.unlock ();
|
||||||
generate_mirrors_list_finished ();
|
generate_mirrors_list_finished ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,7 +1375,7 @@ namespace Pamac {
|
|||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start_get_updates (bool check_aur_updates) {
|
private void get_updates () {
|
||||||
UpdateInfos[] updates_infos = {};
|
UpdateInfos[] updates_infos = {};
|
||||||
unowned Alpm.Package? pkg = null;
|
unowned Alpm.Package? pkg = null;
|
||||||
unowned Alpm.Package? candidate = null;
|
unowned Alpm.Package? candidate = null;
|
||||||
@ -1385,7 +1402,6 @@ namespace Pamac {
|
|||||||
aur_updates = {}
|
aur_updates = {}
|
||||||
};
|
};
|
||||||
get_updates_finished (updates);
|
get_updates_finished (updates);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
string[] local_pkgs = {};
|
string[] local_pkgs = {};
|
||||||
unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache;
|
unowned Alpm.List<unowned Alpm.Package> pkgcache = alpm_handle.localdb.pkgcache;
|
||||||
@ -1474,6 +1490,15 @@ namespace Pamac {
|
|||||||
return aur_updates_infos;
|
return aur_updates_infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void start_get_updates (bool check_aur_updates_) {
|
||||||
|
check_aur_updates = check_aur_updates_;
|
||||||
|
try {
|
||||||
|
thread_pool.add (new AlpmAction (get_updates));
|
||||||
|
} catch (ThreadError e) {
|
||||||
|
stderr.printf ("Thread Error %s\n", e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool trans_init (Alpm.TransFlag flags) {
|
private bool trans_init (Alpm.TransFlag flags) {
|
||||||
current_error = ErrorInfos ();
|
current_error = ErrorInfos ();
|
||||||
if (!databases_lock_mutex.trylock ()) {
|
if (!databases_lock_mutex.trylock ()) {
|
||||||
@ -1517,10 +1542,6 @@ namespace Pamac {
|
|||||||
} else {
|
} else {
|
||||||
success = trans_prepare_real ();
|
success = trans_prepare_real ();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (cancellable.is_cancelled ()) {
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
trans_prepare_finished (success);
|
trans_prepare_finished (success);
|
||||||
}
|
}
|
||||||
@ -1788,15 +1809,21 @@ namespace Pamac {
|
|||||||
} else {
|
} else {
|
||||||
trans_release ();
|
trans_release ();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (cancellable.is_cancelled ()) {
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
trans_prepare_finished (success);
|
trans_prepare_finished (success);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void build_prepare () {
|
private void build_prepare () {
|
||||||
|
if (!databases_lock_mutex.trylock ()) {
|
||||||
|
// Wait for pacman to finish
|
||||||
|
emit_event (0, 0, {});
|
||||||
|
databases_lock_mutex.lock ();
|
||||||
|
}
|
||||||
|
if (cancellable.is_cancelled ()) {
|
||||||
|
cancellable.reset ();
|
||||||
|
databases_lock_mutex.unlock ();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// create a fake aur db
|
// create a fake aur db
|
||||||
try {
|
try {
|
||||||
var list = new StringBuilder ();
|
var list = new StringBuilder ();
|
||||||
@ -1861,7 +1888,17 @@ namespace Pamac {
|
|||||||
to_remove += name;
|
to_remove += name;
|
||||||
}
|
}
|
||||||
// fake trans prepare
|
// fake trans prepare
|
||||||
bool success = trans_init (flags);
|
current_error = ErrorInfos ();
|
||||||
|
bool success = true;
|
||||||
|
if (alpm_handle.trans_init (flags | Alpm.TransFlag.NOLOCK) == -1) {
|
||||||
|
Alpm.Errno errno = alpm_handle.errno ();
|
||||||
|
current_error.errno = (uint) errno;
|
||||||
|
current_error.message = _("Failed to init transaction");
|
||||||
|
if (errno != 0) {
|
||||||
|
current_error.details = { Alpm.strerror (errno) };
|
||||||
|
}
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
foreach (unowned string name in to_install) {
|
foreach (unowned string name in to_install) {
|
||||||
success = trans_add_pkg (name);
|
success = trans_add_pkg (name);
|
||||||
@ -1944,27 +1981,20 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
// get standard handle
|
// get standard handle
|
||||||
refresh_handle ();
|
refresh_handle ();
|
||||||
|
databases_lock_mutex.unlock ();
|
||||||
// launch standard prepare
|
// launch standard prepare
|
||||||
to_install = real_to_install;
|
to_install = real_to_install;
|
||||||
trans_prepare ();
|
trans_prepare ();
|
||||||
} else {
|
|
||||||
// get standard handle
|
|
||||||
refresh_handle ();
|
|
||||||
trans_prepare_finished (false);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trans_release ();
|
trans_release ();
|
||||||
// get standard handle
|
|
||||||
refresh_handle ();
|
|
||||||
trans_prepare_finished (false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (cancellable.is_cancelled ()) {
|
|
||||||
success = true;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
// get standard handle
|
// get standard handle
|
||||||
refresh_handle ();
|
refresh_handle ();
|
||||||
trans_prepare_finished (success);
|
databases_lock_mutex.unlock ();
|
||||||
|
trans_prepare_finished (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user