mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-23 21:33:47 +00:00
android, desktop: alert for local encryption/decryption errors (#4081)
* android, desktop: more alert in case of local encryption/decryption errors * sending a message without a file
This commit is contained in:
1 parent
5ba7b58d7d
commit
68966a1551
10 files changed
+62
-13
No files matched your search
+2
@@ -46,6 +46,7 @@ actual fun shareFile(text: String, fileSource: CryptoFile) {
|
||||
decryptCryptoFile(getAppFilePath(fileSource.filePath), fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to decrypt crypto file: " + e.stackTraceToString())
|
||||
AlertManager.shared.showAlertMsg(title = generalGetString(MR.strings.error), text = e.stackTraceToString())
|
||||
return
|
||||
}
|
||||
getAppFileUri(tmpFile.absolutePath)
|
||||
@@ -112,6 +113,7 @@ fun saveImage(ciFile: CIFile?) {
|
||||
decryptCryptoFile(filePath, ciFile.fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to decrypt crypto file: " + e.stackTraceToString())
|
||||
AlertManager.shared.showAlertMsg(title = generalGetString(MR.strings.error), text = e.stackTraceToString())
|
||||
return@createTmpFileAndDelete
|
||||
}
|
||||
tmpFile.inputStream().use { it.copyTo(outputStream) }
|
||||
|
||||
+8
-1
@@ -27,6 +27,7 @@ import androidx.core.text.HtmlCompat
|
||||
import chat.simplex.common.helpers.*
|
||||
import chat.simplex.common.model.*
|
||||
import chat.simplex.common.platform.*
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import java.io.*
|
||||
import java.net.URI
|
||||
@@ -187,7 +188,13 @@ actual suspend fun getLoadedImage(file: CIFile?): Pair<ImageBitmap, ByteArray>?
|
||||
return if (filePath != null && file != null) {
|
||||
try {
|
||||
val data = if (file.fileSource?.cryptoArgs != null) {
|
||||
readCryptoFile(getAppFilePath(file.fileSource.filePath), file.fileSource.cryptoArgs)
|
||||
try {
|
||||
readCryptoFile(getAppFilePath(file.fileSource.filePath), file.fileSource.cryptoArgs)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to read crypto file: " + e.stackTraceToString())
|
||||
AlertManager.shared.showAlertMsg(title = generalGetString(MR.strings.error), text = e.stackTraceToString())
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
File(getAppFilePath(file.fileName)).readBytes()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user