FIX(server): Look for mumble-server* files

Previously the server was only looking for files named e.g. murmur.ini
or murmur.sqlite. With this commit, the server will now look first for
files called mumble_server.ini and mumble_server.sqlite before falling
back to the old names (for backwards compatibility).

This is meant as a means to drive forward the server renaming from
murmur(d) to mumble-server.
This commit is contained in:
Robert Adam 2022-08-28 18:28:59 +02:00
parent 406ce93b47
commit bf2ee8578c
2 changed files with 32 additions and 26 deletions

View File

@ -72,7 +72,7 @@ MetaParams::MetaParams() {
iDBPort = 0;
qsDBusService = "net.sourceforge.mumble.murmur";
qsDBDriver = "QSQLITE";
qsLogfile = "murmur.log";
qsLogfile = "mumble-server.log";
iLogDays = 31;
@ -169,6 +169,7 @@ void MetaParams::read(QString fname) {
datapaths << appdir.absolutePath() + QLatin1String("/Mumble");
#else
datapaths << QDir::homePath() + QLatin1String("/.murmurd");
datapaths << QDir::homePath() + QLatin1String("/.mumble-server");
datapaths << QDir::homePath() + QLatin1String("/.config/Mumble");
#endif
@ -181,20 +182,24 @@ void MetaParams::read(QString fname) {
datapaths << QDir::currentPath();
datapaths << QCoreApplication::instance()->applicationDirPath();
foreach (const QString &p, datapaths) {
for (const QString &p : datapaths) {
if (!p.isEmpty()) {
QFileInfo fi(p, "murmur.ini");
if (fi.exists() && fi.isReadable()) {
qdBasePath = QDir(p);
qsAbsSettingsFilePath = fi.absoluteFilePath();
break;
// Prefer "mumble-server.ini" but for legacy reasons also keep looking for "murmur.ini"
for (const QString &currentFileName :
{ QStringLiteral("mumble-server.ini"), QStringLiteral("murmur.ini") }) {
QFileInfo fi(p, currentFileName);
if (fi.exists() && fi.isReadable()) {
qdBasePath = QDir(p);
qsAbsSettingsFilePath = fi.absoluteFilePath();
break;
}
}
}
}
if (qsAbsSettingsFilePath.isEmpty()) {
QDir::root().mkpath(qdBasePath.absolutePath());
qdBasePath = QDir(datapaths.at(0));
qsAbsSettingsFilePath = qdBasePath.absolutePath() + QLatin1String("/murmur.ini");
qsAbsSettingsFilePath = qdBasePath.absolutePath() + QLatin1String("/mumble-server.ini");
}
} else {
QFile f(fname);
@ -562,7 +567,7 @@ bool MetaParams::loadSSLSettings() {
QString qsSSLDHParamsIniValue = qsSettings->value(QLatin1String("sslDHParams")).toString();
if (!qsSSLDHParamsIniValue.isEmpty()) {
qFatal("MetaParams: This version of Murmur does not support Diffie-Hellman parameters (sslDHParams). Murmur "
"will not start unless you remove the option from your murmur.ini file.");
"will not start unless you remove the option from your mumble-server.ini (murmur.ini)file.");
return false;
}
#endif

View File

@ -124,32 +124,33 @@ ServerDB::ServerDB() {
found = db->open();
} else {
QStringList datapaths;
int i;
datapaths << Meta::mp.qdBasePath.absolutePath();
datapaths << QDir::currentPath();
datapaths << QCoreApplication::instance()->applicationDirPath();
datapaths << QDir::homePath();
for (i = 0; (i < datapaths.size()) && !found; i++) {
if (!datapaths[i].isEmpty()) {
QFile f(datapaths[i] + "/murmur.sqlite");
if (f.exists()) {
db->setDatabaseName(f.fileName());
found = db->open();
}
}
}
// We use a lambda, so we can easily "break out" of all levels of nested loops using return
[&]() {
for (bool searchExistingDB : { true, false }) {
for (const QString &currentDir : datapaths) {
// Prefer "mumble-server.sqlite", but for legacy reasons also keep looking for "murmur.sqlite"
for (const QString &currentFilename :
{ QStringLiteral("mumble-server.sqlite"), QStringLiteral("murmur.sqlite") }) {
QFile currentFile(currentDir + "/" + currentFilename);
if (!found) {
for (i = 0; (i < datapaths.size()) && !found; i++) {
if (!datapaths[i].isEmpty()) {
QFile f(datapaths[i] + "/murmur.sqlite");
db->setDatabaseName(f.fileName());
found = db->open();
if (!searchExistingDB || currentFile.exists()) {
db->setDatabaseName(currentFile.fileName());
if (db->open()) {
found = true;
return;
}
}
}
}
}
}
}();
}
if (found) {
QFileInfo fi(db->databaseName());