Add default metadata.xml to Athlete config on upgrade

To incorporate new metadata supported in v3.6 to global metadata.xml
for existing users, for new users we use default as before.
Fixes #3913
This commit is contained in:
Alejandro Martinez
2022-08-12 15:53:35 -03:00
parent d4f382e35d
commit e3611455e4

View File

@@ -252,15 +252,22 @@ RideMetadata::configChanged(qint32)
// this was changed to be global configuration since other global
// settings are dependant on them, notably user metrics
bool first=true;
bool addDefault=true;
QStringListIterator i(QDir(gcroot).entryList(QDir::Dirs | QDir::NoDotAndDotDot));
while (i.hasNext()) {
QString name = i.next();
while (i.hasNext() || addDefault) {
QString filename;
if (i.hasNext()) {
// add athlete setup
filename = gcroot + "/" + i.next() + "/config/metadata.xml";
} else {
// add the default setup
filename = ":/xml/metadata.xml";
addDefault = false;
}
// if there is no metadata.xml it is not an athlete folder
// or it is one still using default metadata.xml, so skip it
// since there is no custom configuration to preserve.
QString filename = gcroot + "/" + name + "/config/metadata.xml";
if (!QFile(filename).exists()) continue;
// athlete specific configuration
@@ -323,14 +330,6 @@ RideMetadata::configChanged(qint32)
}
}
// eek, we didn't find anything - new install with no athletes yet
if (first == true) {
// use the default setup
filename = ":/xml/metadata.xml";
readXML(filename, keywordDefinitions, fieldDefinitions, colorfield, defaultDefinitions);
}
// write out global file now, so we don't keep doing this
// "upgrade" process every time we open an athlete etc
filename = QDir(gcroot).absolutePath()+"/metadata.xml";