This commit is contained in:
guinux 2017-08-22 11:11:31 +02:00
parent 9c6c435b05
commit e9076f605e
6 changed files with 38 additions and 10 deletions

View File

@ -138,11 +138,12 @@ class AlpmConfig {
Alpm.Errno error = 0; Alpm.Errno error = 0;
Alpm.Handle? handle = null; Alpm.Handle? handle = null;
if (tmp_db) { if (tmp_db) {
string tmp_dbpath = "/tmp/pamac-checkdbs-%s".printf (Environment.get_user_name ()); string tmp_dbpath = "/tmp/pamac-checkdbs";
try { try {
Process.spawn_command_line_sync ("mkdir -p %s".printf (tmp_dbpath)); Process.spawn_command_line_sync ("mkdir -p %s".printf (tmp_dbpath));
Process.spawn_command_line_sync ("ln -sf %s/local %s".printf (dbpath, tmp_dbpath)); Process.spawn_command_line_sync ("ln -sf %s/local %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("cp -au %s/sync %s".printf (dbpath, tmp_dbpath)); Process.spawn_command_line_sync ("cp -au %s/sync %s".printf (dbpath, tmp_dbpath));
Process.spawn_command_line_sync ("chmod -R 777 %s/sync".printf (tmp_dbpath));
handle = new Alpm.Handle (rootdir, tmp_dbpath, out error); handle = new Alpm.Handle (rootdir, tmp_dbpath, out error);
} catch (SpawnError e) { } catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message); stderr.printf ("SpawnError: %s\n", e.message);

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
const string VERSION = "5.0.0"; const string VERSION = "5.1.0";
namespace Pamac { namespace Pamac {

View File

@ -141,8 +141,8 @@ namespace Pamac {
(alpm_action) => { (alpm_action) => {
alpm_action.run (); alpm_action.run ();
}, },
// two threads at a time // only one thread created so alpm action will run one after one
2, 1,
// no exclusive thread // no exclusive thread
false false
); );
@ -168,7 +168,12 @@ namespace Pamac {
alpm_handle.logcb = (Alpm.LogCallBack) cb_log; alpm_handle.logcb = (Alpm.LogCallBack) cb_log;
lockfile = GLib.File.new_for_path (alpm_handle.lockfile); lockfile = GLib.File.new_for_path (alpm_handle.lockfile);
files_handle = alpm_config.get_handle (true); files_handle = alpm_config.get_handle (true);
files_handle.eventcb = (Alpm.EventCallBack) cb_event;
files_handle.progresscb = (Alpm.ProgressCallBack) cb_progress;
files_handle.questioncb = (Alpm.QuestionCallBack) cb_question;
files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch; files_handle.fetchcb = (Alpm.FetchCallBack) cb_fetch;
files_handle.totaldlcb = (Alpm.TotalDownloadCallBack) cb_totaldownload;
files_handle.logcb = (Alpm.LogCallBack) cb_log;
} }
} }
@ -471,21 +476,30 @@ namespace Pamac {
write_log_file ("synchronizing package lists"); write_log_file ("synchronizing package lists");
cancellable.reset (); cancellable.reset ();
int force = (force_refresh) ? 1 : 0; int force = (force_refresh) ? 1 : 0;
// try to copy refresh dbs in tmp
string tmp_dbpath = "/tmp/pamac-checkdbs";
try {
Process.spawn_command_line_sync ("cp -au %s/sync %s".printf (tmp_dbpath, alpm_handle.dbpath));
} catch (SpawnError e) {
stderr.printf ("SpawnError: %s\n", e.message);
}
// update ".db" // update ".db"
bool success = update_dbs (alpm_handle, force); bool success = update_dbs (alpm_handle, force);
if (cancellable.is_cancelled ()) { if (cancellable.is_cancelled ()) {
refresh_finished (false); refresh_finished (false);
return; return;
} }
if (success) { // 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) {
refreshed = true; refreshed = true;
refresh_finished (true); refresh_finished (true);
} else { } else {
current_error.message = _("Failed to synchronize any databases"); current_error.message = _("Failed to synchronize any databases");
refresh_finished (false); refresh_finished (false);
} }
// update ".files", do it in background, do not need to know if we succeeded
update_dbs (files_handle, force);
} }
public void start_refresh (bool force, GLib.BusName sender) { public void start_refresh (bool force, GLib.BusName sender) {

View File

@ -472,6 +472,9 @@ namespace Pamac {
success = false; success = false;
finish_transaction (); finish_transaction ();
} }
} else {
success = false;
finish_transaction ();
} }
}); });
} }
@ -1396,8 +1399,8 @@ namespace Pamac {
rates_nb = 0; rates_nb = 0;
fraction = 0; fraction = 0;
timer.start (); timer.start ();
if (filename.has_suffix (".db")) { if (filename.has_suffix (".db") || filename.has_suffix (".files")) {
string action = dgettext (null, "Refreshing %s").printf (filename.replace (".db", "")) + "..."; string action = dgettext (null, "Refreshing %s").printf (filename) + "...";
reset_progress_box (action); reset_progress_box (action);
} }
} else if (xfered == total) { } else if (xfered == total) {

View File

@ -220,7 +220,9 @@ namespace Pamac {
} }
} else { } else {
if (lockfile.query_exists ()) { if (lockfile.query_exists ()) {
extern_lock = true; if (!check_pamac_running ()) {
extern_lock = true;
}
} }
} }
return true; return true;

View File

@ -847,6 +847,14 @@ namespace Pamac {
db.update (0); db.update (0);
syncdbs.next (); syncdbs.next ();
} }
// refresh file dbs
var tmp_files_handle = alpm_config.get_handle (true, true);
syncdbs = tmp_files_handle.syncdbs;
while (syncdbs != null) {
unowned Alpm.DB db = syncdbs.data;
db.update (0);
syncdbs.next ();
}
string[] local_pkgs = {}; string[] local_pkgs = {};
unowned Alpm.List<unowned Alpm.Package> pkgcache = tmp_handle.localdb.pkgcache; unowned Alpm.List<unowned Alpm.Package> pkgcache = tmp_handle.localdb.pkgcache;
while (pkgcache != null) { while (pkgcache != null) {