From 31c4c2601df7f2f186aa063619282dc8565efab3 Mon Sep 17 00:00:00 2001 From: Rello Date: Fri, 22 Aug 2025 17:41:52 +0700 Subject: [PATCH] fix: use NOT for account migration option --- CMakeLists.txt | 1 + config.h.in | 1 + src/gui/CMakeLists.txt | 9 +++++++-- src/gui/accountmanager.cpp | 13 ++++++++++++- src/gui/application.cpp | 10 ++++++++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b5c008b93..118f8596dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ else() endif() option( APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG "Display legacy import dialog" ON ) +option( DISABLE_ACCOUNT_MIGRATION "Exclude legacy account migration and import" OFF ) # For usage in XML files we preprocess string(REPLACE "&" "&" APPLICATION_NAME_XML_ESCAPED "${APPLICATION_NAME}") diff --git a/config.h.in b/config.h.in index 1f8ec57476..e4f46791fb 100644 --- a/config.h.in +++ b/config.h.in @@ -38,6 +38,7 @@ #cmakedefine DO_NOT_USE_PROXY "@DO_NOT_USE_PROXY@" #cmakedefine ENFORCE_SINGLE_ACCOUNT "@ENFORCE_SINGLE_ACCOUNT@" #cmakedefine01 APPLICATION_DISPLAY_LEGACY_IMPORT_DIALOG +#cmakedefine01 DISABLE_ACCOUNT_MIGRATION #cmakedefine ZLIB_FOUND @ZLIB_FOUND@ diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 9c16fa412b..d389df77d7 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -153,8 +153,6 @@ set(client_SRCS userinfo.cpp vfsdownloaderrordialog.h vfsdownloaderrordialog.cpp - legacyaccountselectiondialog.h - legacyaccountselectiondialog.cpp accountstate.h accountstate.cpp addcertificatedialog.h @@ -258,6 +256,13 @@ set(client_SRCS wizard/linklabel.cpp ) +if (NOT DISABLE_ACCOUNT_MIGRATION) + list(APPEND client_SRCS + legacyaccountselectiondialog.h + legacyaccountselectiondialog.cpp + ) +endif() + if (WITH_WEBENGINE) list(APPEND client_SRCS wizard/webviewpage.h diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index ac1eaa7e68..3aaba9b60a 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -6,6 +6,7 @@ #include "accountmanager.h" +#include "config.h" #include "sslerrordialog.h" #include "proxyauthhandler.h" #include "creds/credentialsfactory.h" @@ -16,7 +17,9 @@ #include "libsync/cookiejar.h" #include "libsync/theme.h" #include "libsync/clientproxy.h" +#if !DISABLE_ACCOUNT_MIGRATION #include "legacyaccountselectiondialog.h" +#endif #include #include @@ -108,10 +111,12 @@ AccountManager::AccountsRestoreResult AccountManager::restore(const bool alsoRes } // If there are no accounts, check the old format. +#if !DISABLE_ACCOUNT_MIGRATION if (settings->childGroups().isEmpty() && !settings->contains(QLatin1String(versionC)) && alsoRestoreLegacySettings) { restoreFromLegacySettings(); return AccountsRestoreSuccessFromLegacyVersion; } +#endif auto result = AccountsRestoreSuccess; const auto settingsChildGroups = settings->childGroups(); @@ -166,7 +171,7 @@ void AccountManager::backwardMigrationSettingsKeys(QStringList *deleteKeys, QStr deleteKeys->append(settings->group()); } } - +#if !DISABLE_ACCOUNT_MIGRATION bool AccountManager::restoreFromLegacySettings() { qCInfo(lcAccountManager) << "Migrate: restoreFromLegacySettings, checking settings group" @@ -314,6 +319,12 @@ bool AccountManager::restoreFromLegacySettings() return false; } +#else +bool AccountManager::restoreFromLegacySettings() +{ + return false; +} +#endif void AccountManager::save(bool saveCredentials) { diff --git a/src/gui/application.cpp b/src/gui/application.cpp index cebf1c832d..8303e4cd52 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -88,7 +88,9 @@ namespace { " --isvfsenabled : whether to set a VFS or non-VFS folder (1 for 'yes' or 0 for 'no') when creating an account via command-line.\n" " --remotedirpath : (optional) path to a remote subfolder when creating an account via command-line.\n" " --serverurl : a server URL to use when creating an account via command-line.\n" +#if !DISABLE_ACCOUNT_MIGRATION " --forcelegacyconfigimport : forcefully import account configurations from legacy clients (if available).\n" +#endif " --reverse : use a reverse layout direction.\n"; QString applicationTrPath() @@ -875,9 +877,13 @@ void Application::parseOptions(const QStringList &options) if (it.hasNext() && !it.peekNext().startsWith(QLatin1String("--"))) { _setLanguage = it.next(); } - } else if (option == QStringLiteral("--forcelegacyconfigimport")) { + } +#if !DISABLE_ACCOUNT_MIGRATION + else if (option == QStringLiteral("--forcelegacyconfigimport")) { AccountManager::instance()->setForceLegacyImport(true); - } else { + } +#endif + else { QString errorMessage; if (!AccountSetupCommandLineManager::instance()->parseCommandlineOption(option, it, errorMessage)) { if (!errorMessage.isEmpty()) {