[Pkg-owncloud-commits] [owncloud-client] 466/498: 1.8 Migration: Fix password overwrite #3539
Sandro Knauß
hefee-guest at moszumanska.debian.org
Tue Aug 11 14:49:19 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit aee20e0ed3f23ef0c7268a47c07f54835f7ff7b3
Author: Markus Goetz <markus at woboq.com>
Date: Thu Aug 6 12:49:18 2015 +0200
1.8 Migration: Fix password overwrite #3539
---
src/gui/accountmanager.cpp | 14 ++++++++++----
src/gui/accountmanager.h | 4 ++--
src/gui/folderman.cpp | 2 +-
test/stub.cpp | 2 +-
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp
index 6f7f8b4..a90ab9e 100644
--- a/src/gui/accountmanager.cpp
+++ b/src/gui/accountmanager.cpp
@@ -119,21 +119,27 @@ bool AccountManager::restoreFromLegacySettings()
return false;
}
-void AccountManager::save()
+void AccountManager::save(bool saveCredentials)
{
auto settings = Account::settingsWithGroup(QLatin1String(accountsC));
foreach (const auto &acc, _accounts) {
settings->beginGroup(acc->account()->id());
- save(acc->account(), *settings);
+ save(acc->account(), *settings, saveCredentials);
settings->endGroup();
}
}
-void AccountManager::save(const AccountPtr& acc, QSettings& settings)
+void AccountManager::save(const AccountPtr& acc, QSettings& settings, bool saveCredentials)
{
settings.setValue(QLatin1String(urlC), acc->_url.toString());
if (acc->_credentials) {
- acc->_credentials->persist();
+ if (saveCredentials) {
+ // Only persist the credentials if the parameter is set, on migration from 1.8.x
+ // we want to save the accounts but not overwrite the credentials
+ // (This is easier than asynchronously fetching the credentials from keychain and then
+ // re-persisting them)
+ acc->_credentials->persist();
+ }
Q_FOREACH(QString key, acc->_settingsMap.keys()) {
settings.setValue(key, acc->_settingsMap.value(key));
}
diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h
index 6644d84..033ec2a 100644
--- a/src/gui/accountmanager.h
+++ b/src/gui/accountmanager.h
@@ -33,7 +33,7 @@ public:
/**
* Saves the accounts to a given settings file
*/
- void save();
+ void save(bool saveCredentials = true);
/**
* Creates account objects from from a given settings file.
@@ -71,7 +71,7 @@ public:
static AccountPtr createAccount();
private:
- void save(const AccountPtr& account, QSettings& settings);
+ void save(const AccountPtr& account, QSettings& settings, bool saveCredentials = true);
AccountPtr load(QSettings& settings);
bool restoreFromLegacySettings();
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index ad56620..193819c 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -200,7 +200,7 @@ int FolderMan::setupFolders()
if (accountsWithSettings.isEmpty()) {
int r = setupFoldersMigration();
if (r > 0) {
- AccountManager::instance()->save();
+ AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain
}
return r;
}
diff --git a/test/stub.cpp b/test/stub.cpp
index 84fda11..bc9d62a 100644
--- a/test/stub.cpp
+++ b/test/stub.cpp
@@ -2,4 +2,4 @@
#include "accountmanager.h"
OCC::AccountManager *OCC::AccountManager::instance() { return 0; }
-void OCC::AccountManager::save() { }
+void OCC::AccountManager::save(bool saveCredentials) { Q_UNUSED(saveCredentials); }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list