Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stable-3.15: Migration fixes #7806

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 76 additions & 67 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/folderman.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/folderman.cpp

File src/gui/folderman.cpp does not conform to Custom style guidelines. (lines 530, 573)
* Copyright (C) by Klaas Freitag <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -523,89 +524,97 @@
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" << folderGroupName << "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<VfsOff>())) {
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);
qCDebug(lcFolderMan) << folderGroupName << "located at" << path;

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<VfsOff>())) {
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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include "config.h"

Check failure on line 15 in src/libsync/configfile.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/configfile.cpp:15:10 [clang-diagnostic-error]

'config.h' file not found

#include "configfile.h"
#include "theme.h"
Expand Down Expand Up @@ -1263,7 +1263,7 @@
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)) {
Expand Down
Loading