bool AccountManager::restore()
{
auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));
+ if (settings->status() != QSettings::NoError) {
+ qDebug() << "Could not read settings from" << settings->fileName()
+ << settings->status();
+ return false;
+ }
// If there are no accounts, check the old format.
if (settings->childGroups().isEmpty()
&& !settings->contains(QLatin1String(versionC))) {
- return restoreFromLegacySettings();
+ restoreFromLegacySettings();
+ return true;
}
foreach (const auto& accountId, settings->childGroups()) {
bool AccountManager::restoreFromLegacySettings()
{
+ qDebug() << "Migrate: restoreFromLegacySettings, checking settings group"
+ << Theme::instance()->appName();
+
// try to open the correctly themed settings
auto settings = Utility::settingsWithGroup(Theme::instance()->appName());
/**
* Creates account objects from a given settings file.
- * return true if the account was restored
+ *
+ * Returns false if there was an error reading the settings,
+ * but note that settings not existing is not an error.
*/
bool restore();
connect(this, SIGNAL(messageReceived(QString, QObject*)), SLOT(slotParseMessage(QString, QObject*)));
- AccountManager::instance()->restore();
+ if (!AccountManager::instance()->restore()) {
+ // If there is an error reading the account settings, try again
+ // after a couple of seconds, if that fails, give up.
+ // (non-existence is not an error)
+ Utility::sleep(5);
+ if (!AccountManager::instance()->restore()) {
+ qDebug() << "Could not read the account settings, quitting";
+ QMessageBox::critical(
+ 0,
+ tr("Error accessing the configuration file"),
+ tr("There was an error while accessing the configuration "
+ "file at %1.").arg(ConfigFile().configFile()),
+ tr("Quit ownCloud"));
+ QTimer::singleShot(0, qApp, SLOT(quit()));
+ return;
+ }
+ }
FolderMan::instance()->setSyncEnabled(true);