if db is locked, wait for pacman if running else remove the lock
This commit is contained in:
parent
da52dc8953
commit
6bb6de02a7
@ -176,6 +176,10 @@ msgstr ""
|
|||||||
msgid "Transaction cancelled"
|
msgid "Transaction cancelled"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../src/transaction.vala
|
||||||
|
msgid "Waiting for another package manager to quit"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: ../src/transaction.vala
|
#: ../src/transaction.vala
|
||||||
msgid "Checking dependencies"
|
msgid "Checking dependencies"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -194,15 +194,36 @@ namespace Pamac {
|
|||||||
if (!lockfile.query_exists ()) {
|
if (!lockfile.query_exists ()) {
|
||||||
extern_lock = false;
|
extern_lock = false;
|
||||||
refresh_handle ();
|
refresh_handle ();
|
||||||
|
databases_lock_mutex.unlock ();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (lockfile.query_exists ()) {
|
if (lockfile.query_exists ()) {
|
||||||
if (databases_lock_mutex.trylock ()) {
|
if (databases_lock_mutex.trylock ()) {
|
||||||
|
// Functions trans_prepare, sysupgrade_prepare and refresh threads are blocked until unlock.
|
||||||
|
// An extern lock appears, check if pacman running.
|
||||||
|
int exit_status;
|
||||||
|
try {
|
||||||
|
Process.spawn_command_line_sync ("pidof pacman",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
out exit_status);
|
||||||
|
} catch (SpawnError e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
|
if (exit_status == 0) {
|
||||||
extern_lock = true;
|
extern_lock = true;
|
||||||
|
} else {
|
||||||
|
// Pacman is not running: remove the unneeded lock file.
|
||||||
|
try {
|
||||||
|
lockfile.delete ();
|
||||||
|
} catch (Error e) {
|
||||||
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
|
}
|
||||||
databases_lock_mutex.unlock ();
|
databases_lock_mutex.unlock ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,14 +334,9 @@ namespace Pamac {
|
|||||||
commands += "-u";
|
commands += "-u";
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var process = new Subprocess.newv (
|
new Subprocess.newv (
|
||||||
commands,
|
commands,
|
||||||
SubprocessFlags.STDOUT_PIPE | SubprocessFlags.STDERR_MERGE);
|
SubprocessFlags.STDOUT_SILENCE | SubprocessFlags.STDERR_SILENCE);
|
||||||
var dis = new DataInputStream (process.get_stdout_pipe ());
|
|
||||||
string? line;
|
|
||||||
while ((line = dis.read_line ()) != null) {
|
|
||||||
print ("%s\n",line);
|
|
||||||
}
|
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
stderr.printf ("Error: %s\n", e.message);
|
stderr.printf ("Error: %s\n", e.message);
|
||||||
}
|
}
|
||||||
@ -359,7 +375,11 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void refresh () {
|
private void refresh () {
|
||||||
|
if (!databases_lock_mutex.trylock ()) {
|
||||||
|
// Wait for pacman to finish
|
||||||
|
emit_event (0, 0, {});
|
||||||
databases_lock_mutex.lock ();
|
databases_lock_mutex.lock ();
|
||||||
|
}
|
||||||
write_log_file ("synchronizing package lists");
|
write_log_file ("synchronizing package lists");
|
||||||
current_error = ErrorInfos ();
|
current_error = ErrorInfos ();
|
||||||
int force = (force_refresh) ? 1 : 0;
|
int force = (force_refresh) ? 1 : 0;
|
||||||
@ -1292,7 +1312,11 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool trans_init (Alpm.TransFlag flags) {
|
private bool trans_init (Alpm.TransFlag flags) {
|
||||||
|
if (!databases_lock_mutex.trylock ()) {
|
||||||
|
// Wait for pacman to finish
|
||||||
|
emit_event (0, 0, {});
|
||||||
databases_lock_mutex.lock ();
|
databases_lock_mutex.lock ();
|
||||||
|
}
|
||||||
current_error = ErrorInfos ();
|
current_error = ErrorInfos ();
|
||||||
cancellable.reset ();
|
cancellable.reset ();
|
||||||
if (alpm_handle.trans_init (flags) == -1) {
|
if (alpm_handle.trans_init (flags) == -1) {
|
||||||
|
@ -722,6 +722,7 @@ namespace Pamac {
|
|||||||
sysupgrade_simple (enable_downgrade);
|
sysupgrade_simple (enable_downgrade);
|
||||||
} else {
|
} else {
|
||||||
finish_transaction ();
|
finish_transaction ();
|
||||||
|
stop_progressbar_pulse ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -988,6 +989,10 @@ namespace Pamac {
|
|||||||
string? action = null;
|
string? action = null;
|
||||||
string? detailed_action = null;
|
string? detailed_action = null;
|
||||||
switch (primary_event) {
|
switch (primary_event) {
|
||||||
|
case 0: //special case: wait for database lock
|
||||||
|
action = dgettext (null, "Waiting for another package manager to quit") + "...";
|
||||||
|
start_progressbar_pulse ();
|
||||||
|
break;
|
||||||
case 1: //Alpm.Event.Type.CHECKDEPS_START
|
case 1: //Alpm.Event.Type.CHECKDEPS_START
|
||||||
action = dgettext (null, "Checking dependencies") + "...";
|
action = dgettext (null, "Checking dependencies") + "...";
|
||||||
break;
|
break;
|
||||||
@ -1375,6 +1380,7 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void on_refresh_finished (bool success) {
|
void on_refresh_finished (bool success) {
|
||||||
|
stop_progressbar_pulse ();
|
||||||
this.success = success;
|
this.success = success;
|
||||||
clear_lists ();
|
clear_lists ();
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -1389,6 +1395,7 @@ namespace Pamac {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void on_trans_prepare_finished (bool success) {
|
void on_trans_prepare_finished (bool success) {
|
||||||
|
stop_progressbar_pulse ();
|
||||||
this.success = success;
|
this.success = success;
|
||||||
if (success) {
|
if (success) {
|
||||||
show_warnings ();
|
show_warnings ();
|
||||||
|
@ -98,7 +98,10 @@ namespace Pamac {
|
|||||||
stack.add_named (transaction.term_grid, "term");
|
stack.add_named (transaction.term_grid, "term");
|
||||||
transaction_infobox.pack_start (transaction.progress_box);
|
transaction_infobox.pack_start (transaction.progress_box);
|
||||||
|
|
||||||
|
Timeout.add (500, () => {
|
||||||
on_refresh_button_clicked ();
|
on_refresh_button_clicked ();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
stack.notify["visible-child"].connect (on_stack_visible_child_changed);
|
stack.notify["visible-child"].connect (on_stack_visible_child_changed);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user