Modernise FolderMan::setupFoldersHelper, get rid of more single-letter variables

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-04-26 16:15:49 +08:00
parent c2da86c653
commit 7f46084110

View file

@ -284,8 +284,8 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
qCWarning(lcFolderMan) << "Could not load plugin for mode" << folderDefinition.virtualFilesMode; qCWarning(lcFolderMan) << "Could not load plugin for mode" << folderDefinition.virtualFilesMode;
} }
Folder *f = addFolderInternal(folderDefinition, account.data(), std::move(vfs)); const auto folder = addFolderInternal(folderDefinition, account.data(), std::move(vfs));
f->saveToSettings(); folder->saveToSettings();
continue; continue;
} }
@ -316,26 +316,25 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
qFatal("Could not load plugin"); qFatal("Could not load plugin");
} }
Folder *f = addFolderInternal(std::move(folderDefinition), account.data(), std::move(vfs)); if (const auto folder = addFolderInternal(std::move(folderDefinition), account.data(), std::move(vfs))) {
if (f) {
if (switchToVfs) { if (switchToVfs) {
f->switchToVirtualFiles(); folder->switchToVirtualFiles();
} }
// Migrate the old "usePlaceholders" setting to the root folder pin state // Migrate the old "usePlaceholders" setting to the root folder pin state
if (settings.value(QLatin1String(settingsVersionC), 1).toInt() == 1 if (settings.value(QLatin1String(settingsVersionC), 1).toInt() == 1
&& settings.value(QLatin1String("usePlaceholders"), false).toBool()) { && settings.value(QLatin1String("usePlaceholders"), false).toBool()) {
qCInfo(lcFolderMan) << "Migrate: From usePlaceholders to PinState::OnlineOnly"; qCInfo(lcFolderMan) << "Migrate: From usePlaceholders to PinState::OnlineOnly";
f->setRootPinState(PinState::OnlineOnly); folder->setRootPinState(PinState::OnlineOnly);
} }
// Migration: Mark folders that shall be saved in a backwards-compatible way // Migration: Mark folders that shall be saved in a backwards-compatible way
if (backwardsCompatible) if (backwardsCompatible)
f->setSaveBackwardsCompatible(true); folder->setSaveBackwardsCompatible(true);
if (foldersWithPlaceholders) if (foldersWithPlaceholders)
f->setSaveInFoldersWithPlaceholders(); folder->setSaveInFoldersWithPlaceholders();
scheduleFolder(f); scheduleFolder(folder);
emit folderSyncStateChange(f); emit folderSyncStateChange(folder);
} }
} }
settings.endGroup(); settings.endGroup();