unloadAndDeleteAllFolders();
- QStringList skipSettingsKeys;
- backwardMigrationSettingsKeys(&skipSettingsKeys, &skipSettingsKeys);
-
auto settings = ConfigFile::settingsWithGroup(QLatin1String("Accounts"));
const auto accountsWithSettings = settings->childGroups();
if (accountsWithSettings.isEmpty()) {
qCInfo(lcFolderMan) << "Setup folders from settings file";
+ // this is done in Application::configVersionMigration
+ QStringList skipSettingsKeys;
+ backwardMigrationSettingsKeys(&skipSettingsKeys, &skipSettingsKeys);
const auto accounts = AccountManager::instance()->accounts();
for (const auto &account : accounts) {
const auto id = account->account()->id();
qCInfo(lcFolderMan) << "Setup folders from " << configPath << "(migration)";
QDir dir(configPath);
- //We need to include hidden files just in case the alias starts with '.'
+ //We need to include hidden files just in case the alias starts with '.'
dir.setFilter(QDir::Files | QDir::Hidden);
- const auto dirFiles = dir.entryList();
+ //Exclude previous backed up configs e.g. oc.cfg.backup_20230831_133749_4.0.0
+ //only need the current config in use by the legacy application
+ const auto dirFiles = dir.entryList({"*.cfg"});
- // Normally there should be only one account when migrating. TODO: Change
+ // Normally there should be only one account when migrating. TODO: Should assume only one legacy config file
const auto accountState = AccountManager::instance()->accounts().value(0).data();
for (const auto &fileName : dirFiles) {
const auto fullFilePath = dir.filePath(fileName);
- const auto folder = setupFolderFromOldConfigFile(fullFilePath, accountState);
- if (folder) {
- scheduleFolder(folder);
- emit folderSyncStateChange(folder);
- }
+ setupFolderFromOldConfigFile(fullFilePath, accountState);
}
emit folderListChanged(_folderMap);
return a;
}
-// WARNING: Do not remove this code, it is used for predefined/automated deployments (2016)
-Folder *FolderMan::setupFolderFromOldConfigFile(const QString &fileNamePath, AccountState *accountState)
+void FolderMan::setupFolderFromOldConfigFile(const QString &fileNamePath, AccountState *accountState)
{
qCInfo(lcFolderMan) << " ` -> setting up:" << fileNamePath;
QString escapedFileNamePath(fileNamePath);
}
if (!cfgFile.isReadable()) {
qCWarning(lcFolderMan) << "Cannot read folder definition for alias " << cfgFile.filePath();
- return nullptr;
+ return;
}
QSettings settings(escapedFileNamePath, QSettings::IniFormat);
const auto groups = settings.childGroups();
if (groups.isEmpty()) {
qCWarning(lcFolderMan) << "empty file:" << cfgFile.filePath();
- return nullptr;
+ return;
}
if (!accountState) {
qCCritical(lcFolderMan) << "can't create folder without an account";
- return nullptr;
+ return;
}
settings.beginGroup(settingsAccountsC);
qCInfo(lcFolderMan) << "Migrated!" << folder;
settings.sync();
- return folder;
+ if (!folder) {
+ continue;
+ }
+
+ scheduleFolder(folder);
+ emit folderSyncStateChange(folder);
}
settings.endGroup();
settings.endGroup();
}
- return nullptr;
+ return;
}
void FolderMan::slotFolderSyncPaused(Folder *f, bool paused)