Skip to content
Snippets Groups Projects
Commit 1424128d authored by guinux's avatar guinux
Browse files

show progress when checking updates

parent cf28bbde
No related branches found
No related tags found
No related merge requests found
......@@ -356,6 +356,7 @@ namespace Pamac {
transaction.set_pkgreason_finished.connect (on_set_pkgreason_finished);
transaction.generate_mirrors_list.connect (on_generate_mirrors_list);
transaction.run_preferences_dialog_finished.connect (on_run_preferences_dialog_finished);
transaction.get_updates_progress.connect (on_get_updates_progress);
transaction.get_updates_finished.connect (on_get_updates_finished);
// integrate progress box and term widget
......@@ -2533,6 +2534,10 @@ namespace Pamac {
transaction.start_refresh (force_refresh);
}
void on_get_updates_progress (uint percent) {
checking_label.set_markup ("<big><b>%s %u %</b></big>".printf (dgettext (null, "Checking for Updates"), percent));
}
void on_get_updates_finished (Updates updates) {
repos_updates = updates.repos_updates;
aur_updates = updates.aur_updates;
......
......@@ -52,6 +52,7 @@ namespace Pamac {
public abstract void start_get_updates (bool check_aur_updates) throws IOError;
[DBus (no_reply = true)]
public abstract void quit () throws IOError;
public signal void emit_get_updates_progress (uint percent);
public signal void get_updates_finished (Updates updates);
}
[DBus (name = "org.manjaro.pamac.system")]
......@@ -181,6 +182,7 @@ namespace Pamac {
public signal void write_alpm_config_finished (bool checkspace);
public signal void generate_mirrors_list ();
public signal void run_preferences_dialog_finished ();
public signal void get_updates_progress (uint percent);
public signal void get_updates_finished (Updates updates);
public Transaction (Gtk.ApplicationWindow? application_window) {
......@@ -789,6 +791,7 @@ namespace Pamac {
}
public void start_get_updates () {
user_daemon.emit_get_updates_progress.connect (on_emit_get_updates_progress);
user_daemon.get_updates_finished.connect (on_get_updates_finished);
try {
user_daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
......@@ -835,7 +838,13 @@ namespace Pamac {
start_get_updates_for_sysupgrade ();
}
void on_emit_get_updates_progress (uint percent) {
get_updates_progress (percent);
stdout.printf ("%u\n", percent);
}
void on_get_updates_finished (Updates updates) {
user_daemon.emit_get_updates_progress.disconnect (on_emit_get_updates_progress);
user_daemon.get_updates_finished.disconnect (on_get_updates_finished);
get_updates_finished (updates);
}
......
......@@ -94,6 +94,7 @@ namespace Pamac {
private As.Store app_store;
private string locale;
public signal void emit_get_updates_progress (uint percent);
public signal void get_updates_finished (Updates updates);
public UserDaemon () {
......@@ -1212,20 +1213,33 @@ namespace Pamac {
// use a tmp handle
var tmp_handle = alpm_config.get_handle (false, true);
// refresh tmp dbs
// count this step as 45% of the total
emit_get_updates_progress (0);
unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs;
size_t dbs_count = syncdbs.length;
size_t i = 0;
while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
i++;
emit_get_updates_progress ((uint) ((double) i / dbs_count * (double) 45));
}
// refresh file dbs
// count this step as 45% of the total
var tmp_files_handle = alpm_config.get_handle (true, true);
syncdbs = tmp_files_handle.syncdbs;
dbs_count = syncdbs.length;
i = 0;
while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
i++;
emit_get_updates_progress ((uint) ((double) 45 + (double) i / dbs_count * (double) 45));
}
// check updates
// count this step as 5% of the total
string[] local_pkgs = {};
unowned Alpm.List<unowned Alpm.Package> pkgcache = tmp_handle.localdb.pkgcache;
while (pkgcache != null) {
......@@ -1257,8 +1271,10 @@ namespace Pamac {
}
pkgcache.next ();
}
emit_get_updates_progress (95);
if (check_aur_updates) {
// get aur updates
// count this step as 5% of the total
if (!aur_updates_checked) {
AUR.multiinfo.begin (local_pkgs, (obj, res) => {
var aur_updates_json = AUR.multiinfo.end (res);
......@@ -1268,6 +1284,7 @@ namespace Pamac {
repos_updates = repos_updates,
aur_updates = aur_updates
};
emit_get_updates_progress (100);
get_updates_finished (updates);
});
} else {
......@@ -1275,6 +1292,7 @@ namespace Pamac {
repos_updates = repos_updates,
aur_updates = aur_updates
};
emit_get_updates_progress (100);
get_updates_finished (updates);
}
} else {
......@@ -1282,6 +1300,7 @@ namespace Pamac {
repos_updates = repos_updates,
aur_updates = {}
};
emit_get_updates_progress (100);
get_updates_finished (updates);
}
return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment