From e757411d3d46c45c6564f5d6b3c0f1fabe7fd435 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 3 Jul 2018 17:49:45 -0400
Subject: [PATCH] ringaccount: use ERROR_NEED_MIGRATION if necessary

If a migration launched by the daemon fails when decrypting the
account archive, it's because the password is incorrect. The client
should do the migration itself. So, the daemon should informs this
client with ERROR_NEED_MIGRATION

Change-Id: If4871004bf6e09fedcb957b024f50cb723298001
Reviewed-by: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
---
 src/ringdht/ringaccount.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index 61f9f450af..ee467cafd9 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -1392,6 +1392,7 @@ RingAccount::migrateAccount(const std::string& pwd, dht::crypto::Identity& devic
     } catch (...) {
         RING_DBG("[Account %s] Can't load archive", getAccountID().c_str());
         Migration::setState(accountID_, Migration::State::INVALID);
+        setRegistrationState(RegistrationState::ERROR_NEED_MIGRATION);
         return;
     }
 
@@ -1439,6 +1440,7 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string&
                     }
                     catch (...) {
                         Migration::setState(accountID_, Migration::State::INVALID);
+                        setRegistrationState(RegistrationState::ERROR_NEED_MIGRATION);
                         return;
                     }
                     Migration::setState(accountID_, Migration::State::SUCCESS);
-- 
GitLab