Add session path migration to SessionData

This commit is contained in:
Jorge Martín 2024-06-06 16:25:42 +02:00
parent d06656d6bf
commit 67f6bf0d2d
18 changed files with 117 additions and 41 deletions

View file

@ -34,6 +34,7 @@ internal fun SessionData.toDbModel(): DbSessionData {
isTokenValid = if (isTokenValid) 1L else 0L,
loginType = loginType.name,
passphrase = passphrase,
sessionPath = sessionPath,
)
}
@ -50,5 +51,6 @@ internal fun DbSessionData.toApiModel(): SessionData {
isTokenValid = isTokenValid == 1L,
loginType = LoginType.fromName(loginType ?: LoginType.UNKNOWN.name),
passphrase = passphrase,
sessionPath = sessionPath,
)
}

View file

@ -32,7 +32,9 @@ import io.element.encrypteddb.passphrase.RandomSecretPassphraseProvider
object SessionStorageModule {
@Provides
@SingleIn(AppScope::class)
fun provideMatrixDatabase(@ApplicationContext context: Context): SessionDatabase {
fun provideMatrixDatabase(
@ApplicationContext context: Context,
): SessionDatabase {
val name = "session_database"
val secretFile = context.getDatabasePath("$name.key")

View file

@ -23,7 +23,9 @@ CREATE TABLE SessionData (
isTokenValid INTEGER NOT NULL DEFAULT 1,
loginType TEXT,
-- added in version 5
passphrase TEXT
passphrase TEXT,
-- added in version 6
sessionPath TEXT NOT NULL DEFAULT ""
);

View file

@ -0,0 +1,4 @@
-- Migrate DB from version 7
-- Add sessionPath so we can track the anonymized path for the session files dir
ALTER TABLE SessionData ADD COLUMN sessionPath TEXT NOT NULL DEFAULT "";