-
Notifications
You must be signed in to change notification settings - Fork 928
refactor: migration. #9191
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
Open
camilasan
wants to merge
8
commits into
master
Choose a base branch
from
enh/migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+665
−212
Open
refactor: migration. #9191
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
165568e
refactor(migration): add a class to handle the migration logic.
camilasan 4c45852
test(migration): basic class tests.
camilasan 99d2a87
fix(migration): detect upgrade only scenario.
camilasan 489ace4
refactor(migration): move backup config files logic from Application …
camilasan 66af508
refactor(migration): find and readlegacy config files in the Migratio…
camilasan 0b0dc97
refactor(migration): change log level, add comments.
camilasan b1cf250
chore(migration): add extended comment to explain the migration phases.
camilasan 2539f95
fix(migration): update function change from ConfigFile to Migration.
camilasan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,3 @@ | ||||||||
| /* | ||||||||
| * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors | ||||||||
| * SPDX-FileCopyrightText: 2014 ownCloud GmbH | ||||||||
|
|
@@ -33,6 +33,7 @@ | |||||||
| #include "common/vfs.h" | ||||||||
|
|
||||||||
| #include "config.h" | ||||||||
| #include "settings/migration.h" | ||||||||
|
|
||||||||
| #if defined(Q_OS_WIN) | ||||||||
| #include <windows.h> | ||||||||
|
|
@@ -121,21 +122,20 @@ | |||||||
| bool Application::configVersionMigration() | ||||||||
| { | ||||||||
| ConfigFile configFile; | ||||||||
| const auto shouldTryToMigrate = configFile.shouldTryToMigrate(); | ||||||||
| Migration migration; | ||||||||
| const auto shouldTryToMigrate = migration.shouldTryToMigrate(); | ||||||||
| if (!shouldTryToMigrate) { | ||||||||
| qCInfo(lcApplication) << "This is not an upgrade/downgrade/migration. Proceed to read current application config file."; | ||||||||
| configFile.setMigrationPhase(ConfigFile::MigrationPhase::Done); | ||||||||
| migration.setPhase(Migration::Phase::Done); | ||||||||
| return false; | ||||||||
| } | ||||||||
|
|
||||||||
| configFile.setMigrationPhase(ConfigFile::MigrationPhase::SetupConfigFile); | ||||||||
| migration.setPhase(Migration::Phase::SetupConfigFile); | ||||||||
| QStringList deleteKeys, ignoreKeys; | ||||||||
| AccountManager::backwardMigrationSettingsKeys(&deleteKeys, &ignoreKeys); | ||||||||
| FolderMan::backwardMigrationSettingsKeys(&deleteKeys, &ignoreKeys); | ||||||||
| configFile.setClientPreviousVersionString(configFile.clientVersionString()); | ||||||||
|
|
||||||||
| qCDebug(lcApplication) << "Migration is in progress:" << configFile.isMigrationInProgress(); | ||||||||
| const auto versionChanged = configFile.hasVersionChanged(); | ||||||||
| qCDebug(lcApplication) << "Migration is in progress:" << migration.isInProgress(); | ||||||||
| const auto versionChanged = migration.versionChanged(); | ||||||||
| if (versionChanged) { | ||||||||
| qCInfo(lcApplication) << "Version changed. Removing updater settings from config."; | ||||||||
| configFile.cleanUpdaterConfiguration(); | ||||||||
|
|
@@ -181,7 +181,7 @@ | |||||||
| "Continuing will mean <b>%2 these settings</b>.<br>" | ||||||||
| "<br>" | ||||||||
| "The current configuration file was already backed up to <i>%3</i>.") | ||||||||
| .arg((configFile.isDowngrade() ? tr("newer", "newer software version") : tr("older", "older software version")), | ||||||||
| .arg((Migration().isDowngrade() ? tr("newer", "newer software version") : tr("older", "older software version")), | ||||||||
| deleteKeys.isEmpty()? tr("ignoring") : tr("deleting"), | ||||||||
| backupFilesList.join("<br>"))); | ||||||||
| box.addButton(tr("Quit"), QMessageBox::AcceptRole); | ||||||||
|
|
@@ -493,18 +493,18 @@ | |||||||
| { | ||||||||
| _folderManager.reset(new FolderMan); | ||||||||
| ConfigFile configFile; | ||||||||
| configFile.setMigrationPhase(ConfigFile::MigrationPhase::SetupUsers); | ||||||||
| Migration migration; | ||||||||
| migration.setPhase(Migration::Phase::SetupUsers); | ||||||||
| const auto accountsRestoreResult = restoreLegacyAccount(); | ||||||||
| if (accountsRestoreResult == AccountManager::AccountsNotFound || accountsRestoreResult == AccountManager::AccountsRestoreFailure) { | ||||||||
| qCWarning(lcApplication) << "Migration result: " << accountsRestoreResult; | ||||||||
| qCDebug(lcApplication) << "is migration disabled?" << DISABLE_ACCOUNT_MIGRATION; | ||||||||
| qCWarning(lcApplication) << "No accounts were migrated, prompting user to set up accounts and folders from scratch."; | ||||||||
| configFile.setMigrationPhase(ConfigFile::MigrationPhase::Done); | ||||||||
|
|
||||||||
| migration.setPhase(Migration::Phase::Done); | ||||||||
| return; | ||||||||
| } | ||||||||
|
|
||||||||
| configFile.setMigrationPhase(ConfigFile::MigrationPhase::SetupFolders); | ||||||||
| migration.setPhase(Migration::Phase::SetupFolders); | ||||||||
| const auto foldersListSize = FolderMan::instance()->setupFolders(); | ||||||||
| FolderMan::instance()->setSyncEnabled(true); | ||||||||
|
|
||||||||
|
|
@@ -519,6 +519,7 @@ | |||||||
| const auto accounts = AccountManager::instance()->accounts(); | ||||||||
| const auto accountsListSize = accounts.size(); | ||||||||
| if (accountsRestoreResult == AccountManager::AccountsRestoreSuccessFromLegacyVersion | ||||||||
| && accountsListSize > 0 | ||||||||
| && Theme::instance()->displayLegacyImportDialog() | ||||||||
| && !AccountManager::instance()->forceLegacyImport() | ||||||||
| && accountsListSize > 0) { | ||||||||
|
Comment on lines
524
to
525
|
||||||||
| && !AccountManager::instance()->forceLegacyImport() | |
| && accountsListSize > 0) { | |
| && !AccountManager::instance()->forceLegacyImport()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.reset(oCSettings.get())makes thestd::unique_ptrtake ownership of a pointer that is still owned byoCSettings(QSharedPointer). This will lead to double deletion. Use a single ownership model (e.g., keepsettingsas a shared pointer, or haveMigration::legacyData()return astd::unique_ptr<QSettings>and move it intosettings) instead of resetting fromget().