Rename Realm DB file

This commit is contained in:
Benoit Marty 2019-03-20 14:24:51 +01:00
parent 27374aea3f
commit cbd62b9e93
1 changed files with 13 additions and 1 deletions

View File

@ -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
}