Skip to content

Commit fd09466

Browse files
committed
refactor(migration): include more paths to search for legacy config files.
Signed-off-by: Camila Ayres <[email protected]>
1 parent c6375a8 commit fd09466

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/libsync/configfile.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,12 +1379,12 @@ void ConfigFile::findLegacyClientConfigFile()
13791379
// then try to load settings from a very old place
13801380
if (settings->childKeys().isEmpty()) {
13811381
// Legacy settings used QDesktopServices to get the location for the config folder in 2.4 and before
1382-
const auto legacy2_4CfgSettingsLocation = QString(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/data"));
1383-
const auto legacy2_4CfgFileParentFolder = legacy2_4CfgSettingsLocation.left(legacy2_4CfgSettingsLocation.lastIndexOf('/'));
1382+
const auto legacyStandardPaths = QString(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/data"));
1383+
const auto legacyStandardPathsParentFolder = legacyStandardPaths.left(legacyStandardPaths.lastIndexOf('/'));
13841384

13851385
// 2.5+ (rest of 2.x series)
1386-
const auto legacy2_5CfgSettingsLocation = QStandardPaths::writableLocation(Utility::isWindows() ? QStandardPaths::AppDataLocation : QStandardPaths::AppConfigLocation);
1387-
const auto legacy2_5CfgFileParentFolder = legacy2_5CfgSettingsLocation.left(legacy2_5CfgSettingsLocation.lastIndexOf('/'));
1386+
const auto standardPaths = QStandardPaths::writableLocation(Utility::isWindows() ? QStandardPaths::AppDataLocation : QStandardPaths::AppConfigLocation);
1387+
const auto standardPathsParentFolder = standardPaths.left(standardPaths.lastIndexOf('/'));
13881388

13891389
// Now try the locations we use today
13901390
const auto fullLegacyCfgFile = QDir::fromNativeSeparators(settings->fileName());
@@ -1394,17 +1394,21 @@ void ConfigFile::findLegacyClientConfigFile()
13941394
const auto legacyCfgFileNamePath = QString(QStringLiteral("/") + legacyCfgFileNameC);
13951395
const auto legacyCfgFileRelativePath = QString(legacyRelativeConfigLocationC);
13961396

1397-
auto legacyLocations = QVector<QString>{legacy2_4CfgFileParentFolder + legacyCfgFileRelativePath,
1398-
legacy2_5CfgFileParentFolder + legacyCfgFileRelativePath,
1399-
legacyCfgFileParentFolder + legacyCfgFileNamePath,
1400-
legacyCfgFileGrandParentFolder + legacyCfgFileRelativePath};
1397+
auto legacyLocations = QVector<QString>{legacyStandardPathsParentFolder + legacyCfgFileRelativePath,
1398+
standardPathsParentFolder + legacyCfgFileRelativePath,
1399+
legacyCfgFileGrandParentFolder + legacyCfgFileRelativePath,
1400+
legacyCfgFileParentFolder + legacyCfgFileNamePath};
14011401

14021402
if (Theme::instance()->isBranded()) {
14031403
const auto unbrandedCfgFileNamePath = QString(QStringLiteral("/") + unbrandedCfgFileNameC);
14041404
const auto unbrandedCfgFileRelativePath = QString(unbrandedRelativeConfigLocationC);
1405-
legacyLocations.append({legacyCfgFileParentFolder + unbrandedCfgFileNamePath, legacyCfgFileGrandParentFolder + unbrandedCfgFileRelativePath});
1405+
legacyLocations.append({standardPathsParentFolder + unbrandedCfgFileRelativePath,
1406+
legacyCfgFileParentFolder + unbrandedCfgFileNamePath,
1407+
legacyCfgFileGrandParentFolder + unbrandedCfgFileRelativePath});
14061408
}
14071409

1410+
qCInfo(lcConfigFile) << "Paths:" << legacyLocations;
1411+
14081412
for (const auto &configFile : legacyLocations) {
14091413
auto oCSettings = std::make_unique<QSettings>(configFile, QSettings::IniFormat);
14101414
if (oCSettings->status() != QSettings::Status::NoError) {

0 commit comments

Comments
 (0)