qCInfo(lcFolderMan) << "Setup folders from settings file";
- // this is done in Application::configVersionMigration
+ // this is done in Application::configVersionMigration
QStringList skipSettingsKeys;
backwardMigrationSettingsKeys(&skipSettingsKeys, &skipSettingsKeys);
const auto accounts = AccountManager::instance()->accounts();
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);
- //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
+ // 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: Should assume only one legacy config file
if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique<VfsOff>())) {
auto ok = true;
if (const auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList,
- &ok);ok && !legacyBlacklist.isEmpty()) {
+ &ok); ok && !legacyBlacklist.isEmpty()) {
qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist;
- for(const auto &legacyFolder : legacyBlacklist) {
- folder->migrateBlackListPath(legacyFolder);
+ for (const auto &legacyFolder : legacyBlacklist) {
+ folder->migrateBlackListPath(legacyFolder);
}
} else {
qCInfo(lcFolderMan) << "There was a problem retriving the database selective sync for " << folder;
const auto settingLegacyBlacklist = settings.value(QLatin1String("blackList")).toStringList();
if (!settingLegacyBlacklist.empty()) {
- //migrate settings
+ // migrate settings
folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, settingLegacyBlacklist);
settings.remove(QLatin1String("blackList"));
// FIXME: If you remove this codepath, you need to provide another way to do
AccountPtr account = _accountState->account();
- if (const auto newUserId = objData.value("id").toString();!newUserId.isEmpty()) {
+ if (const auto newUserId = objData.value("id").toString(); !newUserId.isEmpty()) {
if (QString::compare(account->davUser(), newUserId, Qt::CaseInsensitive) != 0) {
// TODO: the error message should be in the UI
- qInfo() << "Authed with the wrong user! Please login with the account:" << account->prettyName();
+ qInfo() << "Authenticated with the wrong user! Please login with the account:" << account->prettyName();
if (const auto cred = account->credentials()) {
account->credentials()->askFromUser();
}
return Utility::trailingSlashPath(_confDir);
}
-static const QLatin1String exclFile("sync-exclude.lst");
+static const QLatin1String syncExclFile("sync-exclude.lst");
+static const QLatin1String exclFile("exclude.lst");
QString ConfigFile::excludeFile(Scope scope) const
{
- // prefer sync-exclude.lst, but if it does not exist, check for
- // exclude.lst for compatibility reasons in the user writeable
- // directories.
- QFileInfo fi;
+ if (scope == SystemScope) {
+ return ConfigFile::excludeFileFromSystem();
+ }
- switch (scope) {
- case UserScope:
- fi.setFile(configPath(), exclFile);
+ const auto excludeFilePath = scope == LegacyScope ? discoveredLegacyConfigPath() : configPath();
- if (!fi.isReadable()) {
- fi.setFile(configPath(), QLatin1String("exclude.lst"));
- }
- if (!fi.isReadable()) {
- fi.setFile(configPath(), exclFile);
- }
- return fi.absoluteFilePath();
- case SystemScope:
- return ConfigFile::excludeFileFromSystem();
+ // prefer sync-exclude.lst, but if it does not exist, check for exclude.lst
+ QFileInfo exclFileInfo(excludeFilePath, syncExclFile);
+ if (!exclFileInfo.isReadable()) {
+ exclFileInfo.setFile(excludeFilePath, exclFile);
+ }
+ if (!exclFileInfo.isReadable()) {
+ exclFileInfo.setFile(excludeFilePath, syncExclFile);
}
- ASSERT(false);
- return QString();
+ return exclFileInfo.absoluteFilePath();
}
QString ConfigFile::excludeFileFromSystem()
void ConfigFile::setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles)
{
ConfigFile cfg;
- QString systemList = cfg.excludeFile(ConfigFile::SystemScope);
- QString userList = cfg.excludeFile(ConfigFile::UserScope);
+ const auto systemList = cfg.excludeFile(ConfigFile::SystemScope);
+ const auto userList = cfg.excludeFile(ConfigFile::UserScope);
+ const auto legacyList = cfg.excludeFile(ConfigFile::LegacyScope);
if (!QFile::exists(userList)) {
qCInfo(lcConfigFile) << "User defined ignore list does not exist:" << userList;
- if (!QFile::copy(systemList, userList)) {
- qCInfo(lcConfigFile) << "Could not copy over default list to:" << userList;
+
+ if (QFile::exists(legacyList) && QFile::copy(legacyList, userList)) {
+ qCInfo(lcConfigFile) << "Migrating legacy list" << legacyList << "to user list" << userList;
+
+ } else if (QFile::copy(systemList, userList)) {
+ qCInfo(lcConfigFile) << "Migrating system list" << legacyList << "to user list" << userList;
}
}
if (!QFile::exists(userList)) {
qCInfo(lcConfigFile) << "Adding system ignore list to csync:" << systemList;
excludedFiles.addExcludeFilePath(systemList);
- } else {
- qCInfo(lcConfigFile) << "Adding user defined ignore list to csync:" << userList;
- excludedFiles.addExcludeFilePath(userList);
+ return;
}
+
+ qCInfo(lcConfigFile) << "Adding user defined ignore list to csync:" << userList;
+ excludedFiles.addExcludeFilePath(userList);
}
QString ConfigFile::discoveredLegacyConfigPath()