another try to fix #37, please test and report

This commit is contained in:
guinux 2015-03-27 16:31:07 +01:00
parent 147b8d04c8
commit c578e6bee9
4 changed files with 46 additions and 38 deletions

View File

@ -30,6 +30,11 @@ namespace Pamac {
public bool is_syncfirst;
public UpdateInfos[] repos_updates;
public UpdateInfos[] aur_updates;
public Updates () {
is_syncfirst = false;
repos_updates = {};
aur_updates = {};
}
}
public enum Mode {

View File

@ -35,9 +35,8 @@ namespace Pamac {
public Mutex provider_mutex;
public int? choosen_provider;
private Mutex databases_lock_mutex;
private HashTable<string, Json.Array> aur_results;
private UpdateInfos[] aur_updates;
private bool aur_updates_checked;
private HashTable<string, Json.Array> aur_search_results;
private Json.Array aur_updates_results;
private bool intern_lock;
private bool extern_lock;
@ -61,8 +60,8 @@ namespace Pamac {
public Daemon () {
alpm_config = new Alpm.Config ("/etc/pacman.conf");
databases_lock_mutex = Mutex ();
aur_results = new HashTable<string, Json.Array> (str_hash, str_equal);
aur_updates_checked = false;
aur_search_results = new HashTable<string, Json.Array> (str_hash, str_equal);
aur_updates_results = new Json.Array ();
intern_lock = false;
extern_lock = false;
Timeout.add (500, check_pacman_running);
@ -91,7 +90,6 @@ namespace Pamac {
if (extern_lock) {
if (lockfile.query_exists () == false) {
extern_lock = false;
aur_updates_checked = false;
refresh_handle ();
}
} else {
@ -424,11 +422,11 @@ namespace Pamac {
}
if (search_from_aur) {
Json.Array aur_pkgs;
if (aur_results.contains (search_string)) {
aur_pkgs = aur_results.get (search_string);
if (aur_search_results.contains (search_string)) {
aur_pkgs = aur_search_results.get (search_string);
} else {
aur_pkgs = AUR.search (splitted);
aur_results.insert (search_string, aur_pkgs);
aur_search_results.insert (search_string, aur_pkgs);
}
foreach (var node in aur_pkgs.get_elements ()) {
var aur_pkg = node.get_object ();
@ -613,7 +611,6 @@ namespace Pamac {
var infos = UpdateInfos ();
UpdateInfos[] updates_infos = {};
var updates = Updates ();
updates.aur_updates = {};
unowned Alpm.Package? pkg = null;
unowned Alpm.Package? candidate = null;
foreach (var name in alpm_config.syncfirsts) {
@ -663,18 +660,18 @@ namespace Pamac {
}
}
}
updates.is_syncfirst = false;
updates.repos_updates = updates_infos;
if (enable_aur) {
if (aur_updates_checked == false) {
// get aur updates
aur_updates = {};
var aur_pkgs = AUR.multiinfo (local_pkgs);
if (aur_updates_results.get_length () == 0) {
aur_updates_results = AUR.multiinfo (local_pkgs);
}
int cmp;
unowned Json.Object pkg_info;
string version;
string name;
foreach (var node in aur_pkgs.get_elements ()) {
updates_infos = {};
foreach (var node in aur_updates_results.get_elements ()) {
pkg_info = node.get_object ();
version = pkg_info.get_string_member ("Version");
name = pkg_info.get_string_member ("Name");
@ -685,12 +682,10 @@ namespace Pamac {
infos.db_name = "AUR";
infos.tarpath = pkg_info.get_string_member ("URLPath");
infos.download_size = 0;
aur_updates += infos;
updates_infos += infos;
}
}
aur_updates_checked = true;
}
updates.aur_updates = aur_updates;
updates.aur_updates = updates_infos;
}
return updates;
}

View File

@ -1368,8 +1368,12 @@ namespace Pamac {
Source.remove (pulse_timeout_id);
to_build.steal_all ();
build_status = status;
// let the time to the daemon to update packages
Timeout.add (1000, () => {
var err = ErrorInfos ();
on_trans_commit_finished (err);
return false;
});
}
void on_write_pamac_config_finished (int refresh_period, bool aur_enabled, bool recurse) {

View File

@ -197,7 +197,11 @@ namespace Pamac {
if (locked) {
if (lockfile.query_exists () == false) {
locked = false;
// let the time to the daemon to update packages
Timeout.add (1000, () => {
check_updates ();
return false;
});
}
} else {
if (lockfile.query_exists () == true) {