diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 1bf8cffea81ef..ae5194b0f76cd 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -529,30 +529,30 @@ void Application::setupConfigFile() setApplicationName(_theme->appName()); auto oldDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - - // macOS 10.11.x does not like trailing slash for rename/move. - if (oldDir.endsWith('/')) { - oldDir.chop(1); - } + if (oldDir.endsWith('/')) oldDir.chop(1); // macOS 10.11.x does not like trailing slash for rename/move. if (!QFileInfo(oldDir).isDir()) { return; } - auto confDir = ConfigFile().configPath(); + const QStringList filesList = + !Utility::isWindows() + ? QDir(oldDir).entryList(QDir::Files).filter(QRegularExpression("^(?!.*\\.log).*$")) + : QDir(oldDir).entryList(QDir::Files); - // macOS 10.11.x does not like trailing slash for rename/move. - if (confDir.endsWith('/')) { - confDir.chop(1); + if (filesList.isEmpty()) { + return; } + auto confDir = ConfigFile().configPath(); + if (confDir.endsWith('/')) confDir.chop(1); // macOS 10.11.x does not like trailing slash for rename/move. + qCInfo(lcApplication) << "Migrating old config from" << oldDir << "to" << confDir; if (!QFile::rename(oldDir, confDir)) { qCWarning(lcApplication) << "Failed to move the old config directory to its new location (" << oldDir << "to" << confDir << ")"; // Try to move the files one by one if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) { - const QStringList filesList = QDir(oldDir).entryList(QDir::Files); qCInfo(lcApplication) << "Will move the individual files" << filesList; for (const auto &name : filesList) { if (!QFile::rename(oldDir + "/" + name, confDir + "/" + name)) {