Fix crash when creating an EncryptedFile in Android 6 (#2853)
This commit is contained in:
committed by
GitHub
parent
d103872f42
commit
822705195f
1
changelog.d/2846.bugfix
Normal file
1
changelog.d/2846.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a crash when trying to create an `EncryptedFile` in Android 6.
|
||||
@@ -35,6 +35,13 @@ object SessionStorageModule {
|
||||
fun provideMatrixDatabase(@ApplicationContext context: Context): SessionDatabase {
|
||||
val name = "session_database"
|
||||
val secretFile = context.getDatabasePath("$name.key")
|
||||
|
||||
// Make sure the parent directory of the key file exists, otherwise it will crash in older Android versions
|
||||
val parentDir = secretFile.parentFile
|
||||
if (parentDir != null && !parentDir.exists()) {
|
||||
parentDir.mkdirs()
|
||||
}
|
||||
|
||||
val passphraseProvider = RandomSecretPassphraseProvider(context, secretFile)
|
||||
val driver = SqlCipherDriverFactory(passphraseProvider)
|
||||
.create(SessionDatabase.Schema, "$name.db", context)
|
||||
|
||||
Reference in New Issue
Block a user