From 1778b675a8b8d6ccb1a4c64137b59031c01d4054 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Tue, 14 Jan 2025 17:23:29 +0100 Subject: [PATCH 1/3] Check for FoldersWithPlaceholders when migrating account's folders. Signed-off-by: Camila Ayres --- src/gui/folderman.cpp | 141 ++++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index bb31825b78b47..482fbb47cdf1b 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -42,6 +42,7 @@ namespace { constexpr auto settingsAccountsC = "Accounts"; constexpr auto settingsFoldersC = "Folders"; +constexpr auto settingsFoldersWithPlaceholdersC = "FoldersWithPlaceholders"; constexpr auto settingsVersionC = "version"; constexpr auto maxFoldersVersion = 1; @@ -523,89 +524,95 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc return; } - settings.beginGroup(settingsAccountsC); - qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); - settings.beginGroup(accountState->account()->id()); - settings.beginGroup(settingsFoldersC); - - if (settings.childGroups().isEmpty()) { - qCDebug(lcFolderMan) << "there are no legacy folders for accountId:" << accountState->account()->id(); - return; - } - - const auto childGroups = settings.childGroups(); - for (const auto &alias : childGroups) { - settings.beginGroup(alias); - qCDebug(lcFolderMan) << "try to migrate folder alias:" << alias; - - const auto path = settings.value(QLatin1String("localPath")).toString(); - const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); - const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); - const auto paused = settings.value(QLatin1String("paused"), false).toBool(); - const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); - - if (path.isEmpty()) { - qCDebug(lcFolderMan) << "localPath is empty"; - settings.endGroup(); - continue; - } - - if (targetPath.isEmpty()) { - qCDebug(lcFolderMan) << "targetPath is empty"; - settings.endGroup(); - continue; + auto migrateFoldersGroup = [&](const QString &folderGroupName) { + const auto childGroups = settings.childGroups(); + if (childGroups.isEmpty()) { + qCDebug(lcFolderMan) << "There are no" << folderGroupName << "to migrate from account" << accountState->account()->id(); + return; } + for (const auto &alias : childGroups) { + settings.beginGroup(alias); + qCDebug(lcFolderMan) << "try to migrate folder alias:" << alias; + + const auto path = settings.value(QLatin1String("localPath")).toString(); + const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); + const auto journalPath = settings.value(QLatin1String("journalPath")).toString(); + const auto paused = settings.value(QLatin1String("paused"), false).toBool(); + const auto ignoreHiddenFiles = settings.value(QLatin1String("ignoreHiddenFiles"), false).toBool(); + + if (path.isEmpty()) { + qCDebug(lcFolderMan) << "localPath is empty"; + settings.endGroup(); + continue; + } - if (journalPath.isEmpty()) { - qCDebug(lcFolderMan) << "journalPath is empty"; - settings.endGroup(); - continue; - } + if (targetPath.isEmpty()) { + qCDebug(lcFolderMan) << "targetPath is empty"; + settings.endGroup(); + continue; + } - FolderDefinition folderDefinition; - folderDefinition.alias = alias; - folderDefinition.localPath = path; - folderDefinition.targetPath = targetPath; - folderDefinition.journalPath = journalPath; - folderDefinition.paused = paused; - folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; - - if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique())) { - auto ok = true; - auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, - &ok); - if (!ok) { - qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; + if (journalPath.isEmpty()) { + qCDebug(lcFolderMan) << "journalPath is empty"; + settings.endGroup(); + continue; } - legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); - if (!legacyBlacklist.isEmpty()) { - qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; - for (const auto &legacyFolder : legacyBlacklist) { - folder->migrateBlackListPath(legacyFolder); + FolderDefinition folderDefinition; + folderDefinition.alias = alias; + folderDefinition.localPath = path; + folderDefinition.targetPath = targetPath; + folderDefinition.journalPath = journalPath; + folderDefinition.paused = paused; + folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; + + if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique())) { + auto ok = true; + auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, + &ok); + if (!ok) { + qCInfo(lcFolderMan) << "There was a problem retrieving the database selective sync for " << folder; + } + + legacyBlacklist << settings.value(QLatin1String("blackList")).toStringList(); + if (!legacyBlacklist.isEmpty()) { + qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; + for (const auto &legacyFolder : legacyBlacklist) { + folder->migrateBlackListPath(legacyFolder); + } + settings.remove(QLatin1String("blackList")); } - settings.remove(QLatin1String("blackList")); - } - folder->saveToSettings(); + folder->saveToSettings(); - qCInfo(lcFolderMan) << "Migrated!" << folder->path(); - settings.sync(); + qCInfo(lcFolderMan) << "Migrated!" << folder->path(); + settings.sync(); - if (!folder) { - continue; - } + if (!folder) { + continue; + } - scheduleFolder(folder); - emit folderSyncStateChange(folder); + scheduleFolder(folder); + emit folderSyncStateChange(folder); + } + settings.endGroup(); // folder alias } + }; - settings.endGroup(); - } + settings.beginGroup(settingsAccountsC); + qCDebug(lcFolderMan) << "try to migrate accountId:" << accountState->account()->id(); + settings.beginGroup(accountState->account()->id()); + settings.beginGroup(settingsFoldersWithPlaceholdersC); + migrateFoldersGroup(settingsFoldersWithPlaceholdersC); settings.endGroup(); + + settings.beginGroup(settingsFoldersC); + migrateFoldersGroup(settingsFoldersC); settings.endGroup(); + settings.endGroup(); + settings.endGroup(); return; } From dde403c68625bab5661a17766492cd5347a8c9a8 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Tue, 14 Jan 2025 17:58:42 +0100 Subject: [PATCH 2/3] Improve logs when trying to migrate folders. Signed-off-by: Camila Ayres --- src/gui/folderman.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 482fbb47cdf1b..6ecc3d6929b2c 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -532,7 +532,7 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc } for (const auto &alias : childGroups) { settings.beginGroup(alias); - qCDebug(lcFolderMan) << "try to migrate folder alias:" << alias; + qCDebug(lcFolderMan) << "try to migrate" << folderGroupName << "alias:" << alias; const auto path = settings.value(QLatin1String("localPath")).toString(); const auto targetPath = settings.value(QLatin1String("targetPath")).toString(); @@ -558,6 +558,8 @@ void FolderMan::setupLegacyFolder(const QString &fileNamePath, AccountState *acc continue; } + qCDebug(lcFolderMan) << folderGroupName << "located at" << path; + FolderDefinition folderDefinition; folderDefinition.alias = alias; folderDefinition.localPath = path; From 9e5f9645b87111117958f11ed1920b52687c30da Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Mon, 27 Jan 2025 14:35:55 +0100 Subject: [PATCH 3/3] Overwrite the user exclude list when the client is branded. Enforce specific sync-exclude file to all users. Signed-off-by: Camila Ayres --- src/libsync/configfile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 2b1cda432e597..8e7d571a2d43b 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -1263,7 +1263,7 @@ void ConfigFile::setupDefaultExcludeFilePaths(ExcludedFiles &excludedFiles) if (!QFile::exists(userList)) { qCInfo(lcConfigFile) << "User defined ignore list does not exist:" << userList; - if (QFile::exists(legacyList) && QFile::copy(legacyList, userList)) { + if (!Theme::instance()->isBranded() && QFile::exists(legacyList) && QFile::copy(legacyList, userList)) { qCInfo(lcConfigFile) << "Migrating legacy list" << legacyList << "to user list" << userList; } else if (QFile::copy(systemList, userList)) {