feat: add DB Crash (#1077)

This commit is contained in:
Yogesh Choudhary Paliyal
2025-02-03 23:55:03 +05:30
committed by GitHub
parent 593df60a43
commit 1b6ba34786
2 changed files with 8 additions and 12 deletions
@@ -11,7 +11,7 @@ data class PasswordConfig(
val includeUppercaseLetters: Boolean,
val includeLowercaseLetters: Boolean,
val includeSymbols: Boolean,
val listOfSymbols: List<Char>,
val listOfSymbols: List<Char> = PasswordGenerator.totalSymbol,
val includeNumbers: Boolean,
val includeBlankSpaces: Boolean,
val password: String
@@ -2,7 +2,6 @@ package com.yogeshpaliyal.common.utils
import androidx.datastore.core.Serializer
import com.yogeshpaliyal.common.data.UserSettings
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
import java.io.InputStream
import java.io.OutputStream
@@ -16,16 +15,13 @@ class UserSettingsSerializer(
override suspend fun readFrom(input: InputStream): UserSettings {
val decryptedBytes = cryptoManager.decrypt(input)
return try {
val decodedString = decryptedBytes.decodeToString()
Json.decodeFromString(
deserializer = UserSettings.serializer(),
string = decodedString
)
} catch (e: SerializationException) {
e.printStackTrace()
defaultValue
}
val decodedString = decryptedBytes.decodeToString()
return Json.decodeFromString(
deserializer = UserSettings.serializer(),
string = decodedString
)
}
override suspend fun writeTo(t: UserSettings, output: OutputStream) {