Commit d9b32606 authored by guinux's avatar guinux

refresh files dbs only in background

parent 04535a10
......@@ -451,8 +451,11 @@ namespace Pamac {
refresh_finished (false);
return;
}
// update ".files", do not need to know if we succeeded
update_dbs (files_handle, force);
// only refresh ".files" if force
if (force_refresh) {
// update ".files", do not need to know if we succeeded
update_dbs (files_handle, force);
}
if (cancellable.is_cancelled ()) {
refresh_finished (false);
} else if (success) {
......
......@@ -49,7 +49,7 @@ namespace Pamac {
public abstract string[] get_pkg_files (string pkgname) throws Error;
public abstract async AURPackageDetails get_aur_details (string pkgname) throws Error;
public abstract string[] get_pkg_uninstalled_optdeps (string pkgname) throws Error;
public abstract void start_get_updates (bool check_aur_updates) throws Error;
public abstract void start_get_updates (bool check_aur_updates, bool refresh_files_dbs) throws Error;
[DBus (no_reply = true)]
public abstract void quit () throws Error;
public signal void emit_get_updates_progress (uint percent);
......@@ -793,7 +793,7 @@ namespace Pamac {
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);
user_daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates, false);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
success = false;
......@@ -843,7 +843,6 @@ namespace Pamac {
void on_emit_get_updates_progress (uint percent) {
get_updates_progress (percent);
stdout.printf ("%u\n", percent);
}
void on_get_updates_finished (Updates updates) {
......
......@@ -29,7 +29,7 @@ namespace Pamac {
interface UserDaemon : Object {
public abstract void refresh_handle () throws Error;
public abstract string get_lockfile () throws Error;
public abstract void start_get_updates (bool check_aur_updates) throws Error;
public abstract void start_get_updates (bool check_aur_updates, bool refresh_files_dbs) throws Error;
[DBus (no_reply = true)]
public abstract void quit () throws Error;
public signal void get_updates_finished (Updates updates);
......@@ -117,7 +117,7 @@ namespace Pamac {
var pamac_config = new Pamac.Config ("/etc/pamac.conf");
if (pamac_config.refresh_period != 0) {
try {
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates);
daemon.start_get_updates (pamac_config.enable_aur && pamac_config.check_aur_updates, true);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
......
......@@ -88,6 +88,7 @@ namespace Pamac {
private AlpmPackage[] repos_updates;
private bool check_aur_updates;
private bool aur_updates_checked;
private bool refresh_files_dbs;
private AURPackage[] aur_updates;
private HashTable<string, Json.Array> aur_search_results;
private HashTable<string, Json.Object> aur_infos;
......@@ -1217,7 +1218,7 @@ 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
// count this step as 90% of the total
emit_get_updates_progress (0);
unowned Alpm.List<unowned Alpm.DB> syncdbs = tmp_handle.syncdbs;
size_t dbs_count = syncdbs.length;
......@@ -1227,20 +1228,21 @@ namespace Pamac {
db.update (0);
syncdbs.next ();
i++;
emit_get_updates_progress ((uint) ((double) i / dbs_count * (double) 45));
emit_get_updates_progress ((uint) ((double) i / dbs_count * (double) 90));
}
// 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));
if (refresh_files_dbs) {
// refresh file dbs
// do not send progress because it is done in background
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++;
}
}
// check updates
// count this step as 5% of the total
......@@ -1325,8 +1327,9 @@ namespace Pamac {
});
}
public void start_get_updates (bool check_aur_updates_) throws Error {
public void start_get_updates (bool check_aur_updates_, bool refresh_files_dbs_) throws Error {
check_aur_updates = check_aur_updates_;
refresh_files_dbs = refresh_files_dbs_;
new Thread<int> ("get updates thread", get_updates);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment