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:
Ken Moore
2016-12-02 10:27:02 -05:00
parent 8da65605c2
commit 4bedde7244

View File

@@ -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);
}