reset database immediately when the new account is stored (otherwise this might lead to inconsistency)

This commit is contained in:
David Luhmer 2019-04-11 14:02:18 -03:00
parent f053229879
commit 842b7be3a3

View file

@ -252,6 +252,8 @@ public class LoginDialogActivity extends AppCompatActivity {
editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, true); editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, true);
editor.commit(); editor.commit();
resetDatabase();
SingleAccountHelper.setCurrentAccount(this, importedAccount.name); SingleAccountHelper.setCurrentAccount(this, importedAccount.name);
mApi.initApi(new NextcloudAPI.ApiConnectedListener() { mApi.initApi(new NextcloudAPI.ApiConnectedListener() {
@ -337,6 +339,8 @@ public class LoginDialogActivity extends AppCompatActivity {
editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, false); editor.putBoolean(SettingsActivity.SW_USE_SINGLE_SIGN_ON, false);
editor.commit(); editor.commit();
resetDatabase();
final ProgressDialog dialogLogin = buildPendingDialogWhileLoggingIn(); final ProgressDialog dialogLogin = buildPendingDialogWhileLoggingIn();
dialogLogin.show(); dialogLogin.show();
@ -357,6 +361,12 @@ public class LoginDialogActivity extends AppCompatActivity {
} }
} }
private void resetDatabase() {
//Reset Database
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(LoginDialogActivity.this);
dbConn.resetDatabase();
}
private void finishLogin(final ProgressDialog dialogLogin) { private void finishLogin(final ProgressDialog dialogLogin) {
mApi.getAPI().version() mApi.getAPI().version()
.subscribeOn(Schedulers.newThread()) .subscribeOn(Schedulers.newThread())
@ -409,10 +419,6 @@ public class LoginDialogActivity extends AppCompatActivity {
Log.v(TAG, "onComplete() called"); Log.v(TAG, "onComplete() called");
if(loginSuccessful) { if(loginSuccessful) {
//Reset Database
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(LoginDialogActivity.this);
dbConn.resetDatabase();
Intent returnIntent = new Intent(); Intent returnIntent = new Intent();
setResult(RESULT_OK, returnIntent); setResult(RESULT_OK, returnIntent);