Skip to content

Commit

Permalink
change cipher_profile value to be platform specific
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk committed Dec 10, 2024
1 parent 859e788 commit 85de0cf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ actual fun userDatabaseBuilder(
) {
isWALEnabled = enableWAL
}
return UserDatabaseBuilder(userId, driver, dispatcher, platformDatabaseData, isEncryptionEnabled)
return UserDatabaseBuilder(
userId = userId,
sqlDriver = driver,
dispatcher = dispatcher,
platformDatabaseData = platformDatabaseData,
isEncrypted = isEncryptionEnabled,
cipherProfile = "logcat",
)
}

actual fun userDatabaseDriverByPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class UserDatabaseBuilder internal constructor(
dispatcher: CoroutineDispatcher,
private val platformDatabaseData: PlatformDatabaseData,
private val isEncrypted: Boolean,
private val queriesContext: CoroutineContext = KaliumDispatcherImpl.io
private val queriesContext: CoroutineContext = KaliumDispatcherImpl.io,
private val cipherProfile: String? = null,
) {

internal val database: UserDatabase = UserDatabase(
Expand Down Expand Up @@ -317,12 +318,12 @@ class UserDatabaseBuilder internal constructor(
fun dbFileLocation(): String? = getDatabaseAbsoluteFileLocation(platformDatabaseData, userId)

/**
* Changes the profiling of the encrypted database (cipher_profile)
* Changes the profiling of the database (cipher_profile) if the profile is specified and the database is encrypted
* @param enabled true to enable profiling, false to disable
*/
fun changeProfiling(enabled: Boolean) {
if (isEncrypted) {
val cipherProfileValue = if (enabled) "logcat" else "off"
if (isEncrypted && cipherProfile != null) {
val cipherProfileValue = if (enabled) cipherProfile else "off"
sqlDriver.executeQuery(
identifier = null,
sql = "PRAGMA cipher_profile='$cipherProfileValue'",
Expand Down

0 comments on commit 85de0cf

Please sign in to comment.