Skip to content

Commit

Permalink
Merge pull request #7637 from nextcloud/backport/7635/stable-3.15
Browse files Browse the repository at this point in the history
[stable-3.15] Bug fix import of unbranded account
  • Loading branch information
mgallien authored Dec 11, 2024
2 parents 179cea1 + 093188b commit cb42a8c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
17 changes: 13 additions & 4 deletions src/gui/accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ constexpr auto networkProxyPasswordKeychainKeySuffixC = "_proxy_password";
constexpr auto legacyRelativeConfigLocationC = "/ownCloud/owncloud.cfg";
constexpr auto legacyCfgFileNameC = "owncloud.cfg";

constexpr auto unbrandedRelativeConfigLocationC = "/Nextcloud/nextcloud.cfg";
constexpr auto unbrandedCfgFileNameC = "nextcloud.cfg";

// The maximum versions that this client can read
constexpr auto maxAccountsVersion = 2;
constexpr auto maxAccountVersion = 1;
Expand Down Expand Up @@ -192,10 +195,16 @@ bool AccountManager::restoreFromLegacySettings()
const auto legacyCfgFileNamePath = QString(QStringLiteral("/") + legacyCfgFileNameC);
const auto legacyCfgFileRelativePath = QString(legacyRelativeConfigLocationC);

const auto legacyLocations = QVector<QString>{legacy2_4CfgFileParentFolder + legacyCfgFileRelativePath,
legacy2_5CfgFileParentFolder + legacyCfgFileRelativePath,
legacyCfgFileParentFolder + legacyCfgFileNamePath,
legacyCfgFileGrandParentFolder + legacyCfgFileRelativePath};
auto legacyLocations = QVector<QString>{legacy2_4CfgFileParentFolder + legacyCfgFileRelativePath,
legacy2_5CfgFileParentFolder + legacyCfgFileRelativePath,
legacyCfgFileParentFolder + legacyCfgFileNamePath,
legacyCfgFileGrandParentFolder + legacyCfgFileRelativePath};

if (Theme::instance()->isBranded()) {
const auto unbrandedCfgFileNamePath = QString(QStringLiteral("/") + unbrandedCfgFileNameC);
const auto unbrandedCfgFileRelativePath = QString(unbrandedRelativeConfigLocationC);
legacyLocations.append({legacyCfgFileParentFolder + unbrandedCfgFileNamePath, legacyCfgFileGrandParentFolder + unbrandedCfgFileRelativePath});
}

for (const auto &configFile : legacyLocations) {
auto oCSettings = std::make_unique<QSettings>(configFile, QSettings::IniFormat);
Expand Down
40 changes: 24 additions & 16 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,23 +483,31 @@ void Application::setupAccountsAndFolders()
if (const auto accounts = AccountManager::instance()->accounts();
accountsRestoreResult == AccountManager::AccountsRestoreSuccessFromLegacyVersion
&& !accounts.isEmpty()) {

const auto accountsListSize = accounts.size();
const auto accountsRestoreMessage = accountsListSize > 1
? tr("%1 accounts", "number of accounts imported").arg(QString::number(accountsListSize))
: tr("1 account");
const auto foldersRestoreMessage = foldersListSize > 1
? tr("%1 folders", "number of folders imported").arg(QString::number(foldersListSize))
: tr("1 folder");
const auto messageBox = new QMessageBox(QMessageBox::Information,
tr("Legacy import"),
tr("Imported %1 and %2 from a legacy desktop client.\n%3",
"number of accounts and folders imported. list of users.")
.arg(accountsRestoreMessage,
foldersRestoreMessage,
prettyNamesList(accounts))
);
messageBox->setWindowModality(Qt::NonModal);
messageBox->open();
if (Theme::instance()->displayLegacyImportDialog()) {
const auto accountsRestoreMessage = accountsListSize > 1
? tr("%1 accounts", "number of accounts imported").arg(QString::number(accountsListSize))
: tr("1 account");
const auto foldersRestoreMessage = foldersListSize > 1
? tr("%1 folders", "number of folders imported").arg(QString::number(foldersListSize))
: tr("1 folder");
const auto messageBox = new QMessageBox(QMessageBox::Information,
tr("Legacy import"),
tr("Imported %1 and %2 from a legacy desktop client.\n%3",
"number of accounts and folders imported. list of users.")
.arg(accountsRestoreMessage,
foldersRestoreMessage,
prettyNamesList(accounts))
);
messageBox->setWindowModality(Qt::NonModal);
messageBox->open();
}

qCWarning(lcApplication) << "Migration result AccountManager::AccountsRestoreResult:" << accountsRestoreResult;
qCWarning(lcApplication) << "Folders migrated: " << foldersListSize;
qCWarning(lcApplication) << accountsListSize << "account(s) were migrated:" << prettyNamesList(accounts);

} else {
qCWarning(lcApplication) << "Migration result AccountManager::AccountsRestoreResult: " << accountsRestoreResult;
qCWarning(lcApplication) << "Folders migrated: " << foldersListSize;
Expand Down

0 comments on commit cb42a8c

Please sign in to comment.