From cbd62b9e93317015a74b1c76a035023284f25427 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 20 Mar 2019 14:24:51 +0100 Subject: [PATCH] Rename Realm DB file --- .../matrix/android/internal/auth/AuthModule.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/AuthModule.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/AuthModule.kt index 2ec3e73f6c..8e7c63982d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/AuthModule.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/auth/AuthModule.kt @@ -16,11 +16,13 @@ package im.vector.matrix.android.internal.auth +import android.content.Context import im.vector.matrix.android.api.auth.Authenticator import im.vector.matrix.android.internal.auth.db.RealmSessionParamsStore import im.vector.matrix.android.internal.auth.db.SessionParamsMapper import io.realm.RealmConfiguration import org.koin.dsl.module.module +import java.io.File class AuthModule { @@ -31,8 +33,18 @@ class AuthModule { } single { + val context: Context = get() + val old = File(context.filesDir, "matrix-sdk-auth") + + if (old.exists()) { + old.renameTo(File(context.filesDir, "matrix-sdk-auth.realm")) + } + val mapper = SessionParamsMapper((get())) - val realmConfiguration = RealmConfiguration.Builder().name("matrix-sdk-auth").deleteRealmIfMigrationNeeded().build() + val realmConfiguration = RealmConfiguration.Builder() + .name("matrix-sdk-auth.realm") + .deleteRealmIfMigrationNeeded() + .build() RealmSessionParamsStore(mapper, realmConfiguration) as SessionParamsStore }