mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
Adjust the check for valid pkg repos to better catch when the databases are out of sync and update as needed.
This commit is contained in:
@@ -331,11 +331,7 @@ QJsonArray PKG::list_categories(QString repo){
|
||||
QJsonArray PKG::list_repos(bool updated){
|
||||
QString dbdir = "/var/db/pkg/repo-%1.sqlite";
|
||||
QDir confdir("/usr/local/etc/pkg/repos");
|
||||
QStringList confs = confdir.entryList(QStringList() << "*.conf", QDir::Files);
|
||||
if(confs.isEmpty() && !updated){
|
||||
QProcess::execute("pkg update"); //need to update pkg configs
|
||||
return list_repos(true); //try again recursively (will not try to update again)
|
||||
}
|
||||
QStringList confs = confdir.entryList(QStringList() << "*.conf", QDir::Files);
|
||||
QStringList found;
|
||||
found << "local"; //There is always a local database (for installed pkgs)
|
||||
for(int i=0; i<confs.length(); i++){
|
||||
@@ -345,6 +341,11 @@ QJsonArray PKG::list_repos(bool updated){
|
||||
if(QFile::exists(dbdir.arg(repo)) && repoinfo[j].section("enabled:",1,-1).section(":",0,0).contains("true")){ found << repo; }
|
||||
}
|
||||
}
|
||||
if(found.length()<2 && !updated){
|
||||
//Only the local repo could be found - update the package repos and try again
|
||||
QProcess::execute("pkg update");
|
||||
return list_repos(true); //try again recursively (will not try to update again)
|
||||
}
|
||||
return QJsonArray::fromStringList(found);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user