From: Camila Date: Sun, 27 Aug 2023 21:32:05 +0000 (+0200) Subject: Migrate selective sync db list. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~9^2~20^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6f38545e09e5b8498eb567dd9ea4718bf1334bbe;p=nextcloud-desktop.git Migrate selective sync db list. - Refactor migration of blacklisted folders. - Only change selective sync list if needed. Signed-off-by: Camila --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 2aa8ee48e..92b05d269 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -893,6 +893,14 @@ void Folder::blacklistPath(const QString &path) appendPathToSelectiveSyncList(path, SyncJournalDb::SelectiveSyncBlackList); } +void Folder::migrateBlackListPath(const QString &legacyPath) +{ + if (legacyPath.startsWith(QLatin1Char('/'))) { + removePathFromSelectiveSyncList(legacyPath, SyncJournalDb::SelectiveSyncBlackList); + blacklistPath(legacyPath.mid(1)); + } +} + bool Folder::isFileExcludedAbsolute(const QString &fullPath) const { return _engine->excludedFiles().isExcluded(fullPath, path(), _definition.ignoreHiddenFiles); diff --git a/src/gui/folder.h b/src/gui/folder.h index f0459a9f0..edc8484b4 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -303,6 +303,7 @@ public: void whitelistPath(const QString &path); void blacklistPath(const QString &path); + void migrateBlackListPath(const QString &legacyPath); signals: void syncStateChange(); diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 3c6f012e1..b69c1cfd4 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -563,10 +563,21 @@ void FolderMan::setupFolderFromOldConfigFile(const QString &fileNamePath, Accoun folderDefinition.ignoreHiddenFiles = ignoreHiddenFiles; if (const auto folder = addFolderInternal(folderDefinition, accountState, std::make_unique())) { - const auto blackList = settings.value(QLatin1String("blackList")).toStringList(); - if (!blackList.empty()) { + auto ok = true; + if (const auto legacyBlacklist = folder->journalDb()->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, + &ok);ok && !legacyBlacklist.isEmpty()) { + qCInfo(lcFolderMan) << "Legacy selective sync list found:" << legacyBlacklist; + 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 - folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, blackList); + folder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, settingLegacyBlacklist); settings.remove(QLatin1String("blackList")); // FIXME: If you remove this codepath, you need to provide another way to do // this via theme.h or the normal FolderMan::setupFolders @@ -574,7 +585,7 @@ void FolderMan::setupFolderFromOldConfigFile(const QString &fileNamePath, Accoun folder->saveToSettings(); - qCInfo(lcFolderMan) << "Migrated!" << folder; + qCInfo(lcFolderMan) << "Migrated!" << folder->path(); settings.sync(); if (!folder) {