mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-28 12:09:41 +00:00
android, desktop: check existence before deleting database (#5298)
This commit is contained in:
+4
-1
@@ -719,13 +719,16 @@ private fun deleteChatAlert(onConfirm: () -> Unit) {
|
||||
}
|
||||
|
||||
private suspend fun deleteChat(m: ChatModel, progressIndicator: MutableState<Boolean>) {
|
||||
if (!DatabaseUtils.hasAtLeastOneDatabase(dataDir.absolutePath)) {
|
||||
return
|
||||
}
|
||||
progressIndicator.value = true
|
||||
try {
|
||||
deleteChatAsync(m)
|
||||
operationEnded(m, progressIndicator) {
|
||||
AlertManager.shared.showAlertMsg(generalGetString(MR.strings.chat_database_deleted), generalGetString(MR.strings.restart_the_app_to_create_a_new_chat_profile))
|
||||
}
|
||||
} catch (e: Error) {
|
||||
} catch (e: Throwable) {
|
||||
operationEnded(m, progressIndicator) {
|
||||
AlertManager.shared.showAlertMsg(generalGetString(MR.strings.error_deleting_database), e.toString())
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ object DatabaseUtils {
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasAtLeastOneDatabase(rootDir: String): Boolean =
|
||||
fun hasAtLeastOneDatabase(rootDir: String): Boolean =
|
||||
File(rootDir + File.separator + chatDatabaseFileName).exists() || File(rootDir + File.separator + agentDatabaseFileName).exists()
|
||||
|
||||
fun hasOnlyOneDatabase(rootDir: String): Boolean =
|
||||
|
||||
Reference in New Issue
Block a user