forked from cromer/pamac-classic
fix #260
This commit is contained in:
parent
57acdc25f3
commit
bd81be2659
@ -134,7 +134,7 @@ class AlpmConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alpm.Handle? get_handle () {
|
public Alpm.Handle? get_handle (bool files_db = false) {
|
||||||
Alpm.Errno error;
|
Alpm.Errno error;
|
||||||
Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, out error);
|
Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, out error);
|
||||||
if (error == Alpm.Errno.DB_VERSION) {
|
if (error == Alpm.Errno.DB_VERSION) {
|
||||||
@ -150,6 +150,9 @@ class AlpmConfig {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// define options
|
// define options
|
||||||
|
if (files_db) {
|
||||||
|
handle.dbext = ".files";
|
||||||
|
}
|
||||||
handle.logfile = logfile;
|
handle.logfile = logfile;
|
||||||
handle.gpgdir = gpgdir;
|
handle.gpgdir = gpgdir;
|
||||||
handle.arch = arch;
|
handle.arch = arch;
|
||||||
@ -195,20 +198,6 @@ class AlpmConfig {
|
|||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Alpm.Handle? get_files_handle () {
|
|
||||||
Alpm.Handle? handle = new Alpm.Handle (rootdir, dbpath, null);
|
|
||||||
if (handle == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// define options
|
|
||||||
handle.dbext = ".files";
|
|
||||||
// register dbs
|
|
||||||
foreach (unowned AlpmRepo repo in repo_order) {
|
|
||||||
handle.register_syncdb (repo.name, 0);
|
|
||||||
}
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void parse_file (string path, string? section = null) {
|
void parse_file (string path, string? section = null) {
|
||||||
string? current_section = section;
|
string? current_section = section;
|
||||||
var file = GLib.File.new_for_path (path);
|
var file = GLib.File.new_for_path (path);
|
||||||
|
@ -223,7 +223,7 @@ 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_files_handle ();
|
files_handle = alpm_config.get_handle (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool check_extern_lock () {
|
private bool check_extern_lock () {
|
||||||
@ -452,6 +452,31 @@ namespace Pamac {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool update_dbs (Alpm.Handle handle, int force) {
|
||||||
|
bool success = false;
|
||||||
|
unowned Alpm.List<unowned Alpm.DB> syncdbs = handle.syncdbs;
|
||||||
|
while (syncdbs != null) {
|
||||||
|
if (cancellable.is_cancelled ()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unowned Alpm.DB db = syncdbs.data;
|
||||||
|
if (db.update (force) >= 0) {
|
||||||
|
success = true;
|
||||||
|
} else {
|
||||||
|
Alpm.Errno errno = handle.errno ();
|
||||||
|
current_error.errno = (uint) errno;
|
||||||
|
if (errno != 0) {
|
||||||
|
// download error details are set in cb_fetch
|
||||||
|
if (errno != Alpm.Errno.EXTERNAL_DOWNLOAD) {
|
||||||
|
current_error.details = { Alpm.strerror (errno) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
syncdbs.next ();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
private void refresh () {
|
private void refresh () {
|
||||||
current_error = ErrorInfos ();
|
current_error = ErrorInfos ();
|
||||||
if (!databases_lock_mutex.trylock ()) {
|
if (!databases_lock_mutex.trylock ()) {
|
||||||
@ -466,44 +491,26 @@ namespace Pamac {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write_log_file ("synchronizing package lists");
|
write_log_file ("synchronizing package lists");
|
||||||
int force = (force_refresh) ? 1 : 0;
|
|
||||||
uint success = 0;
|
|
||||||
cancellable.reset ();
|
cancellable.reset ();
|
||||||
string[] dbexts = {".db", ".files"};
|
int force = (force_refresh) ? 1 : 0;
|
||||||
unowned Alpm.List<unowned Alpm.DB> syncdbs = alpm_handle.syncdbs;
|
// update ".db"
|
||||||
while (syncdbs != null) {
|
bool success = update_dbs (alpm_handle, force);
|
||||||
unowned Alpm.DB db = syncdbs.data;
|
if (cancellable.is_cancelled ()) {
|
||||||
if (cancellable.is_cancelled ()) {
|
refresh_finished (false);
|
||||||
alpm_handle.dbext = ".db";
|
databases_lock_mutex.unlock ();
|
||||||
refresh_finished (false);
|
return;
|
||||||
databases_lock_mutex.unlock ();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
foreach (unowned string dbext in dbexts) {
|
|
||||||
alpm_handle.dbext = dbext;
|
|
||||||
if (db.update (force) >= 0) {
|
|
||||||
success++;
|
|
||||||
} else {
|
|
||||||
Alpm.Errno errno = alpm_handle.errno ();
|
|
||||||
current_error.errno = (uint) errno;
|
|
||||||
if (errno != 0) {
|
|
||||||
// download error details are set in cb_fetch
|
|
||||||
if (errno != Alpm.Errno.EXTERNAL_DOWNLOAD) {
|
|
||||||
current_error.details = { Alpm.strerror (errno) };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
syncdbs.next ();
|
|
||||||
}
|
}
|
||||||
alpm_handle.dbext = ".db";
|
// update ".files", do not need to know if we succeeded
|
||||||
// We should always succeed if at least one DB was upgraded - we may possibly
|
update_dbs (files_handle, force);
|
||||||
// fail later with unresolved deps, but that should be rare, and would be expected
|
if (cancellable.is_cancelled ()) {
|
||||||
if (success == 0) {
|
refresh_finished (false);
|
||||||
|
} else if (success) {
|
||||||
|
// We should always succeed if at least one DB was upgraded - we may possibly
|
||||||
|
// fail later with unresolved deps, but that should be rare, and would be expected
|
||||||
|
refresh_finished (true);
|
||||||
|
} else {
|
||||||
current_error.message = _("Failed to synchronize any databases");
|
current_error.message = _("Failed to synchronize any databases");
|
||||||
refresh_finished (false);
|
refresh_finished (false);
|
||||||
} else {
|
|
||||||
refresh_finished (true);
|
|
||||||
}
|
}
|
||||||
databases_lock_mutex.unlock ();
|
databases_lock_mutex.unlock ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user