mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-22 12:02:26 +00:00
desktop: catch unreadable crypto file (#3359)
This commit is contained in:
1 parent
5beeff5cb6
commit
338417d963
6 files changed
+41
-9
No files matched your search
+14
-3
@@ -35,7 +35,12 @@ actual fun shareFile(text: String, fileSource: CryptoFile) {
|
||||
val tmpFile = File(tmpDir, fileSource.filePath)
|
||||
tmpFile.deleteOnExit()
|
||||
ChatModel.filesToDelete.add(tmpFile)
|
||||
decryptCryptoFile(getAppFilePath(fileSource.filePath), fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
try {
|
||||
decryptCryptoFile(getAppFilePath(fileSource.filePath), fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to decrypt crypto file: " + e.stackTraceToString())
|
||||
return
|
||||
}
|
||||
getAppFileUri(tmpFile.absolutePath)
|
||||
} else {
|
||||
getAppFileUri(fileSource.filePath)
|
||||
@@ -96,15 +101,21 @@ fun saveImage(ciFile: CIFile?) {
|
||||
val outputStream = BufferedOutputStream(stream)
|
||||
if (ciFile.fileSource?.cryptoArgs != null) {
|
||||
createTmpFileAndDelete { tmpFile ->
|
||||
decryptCryptoFile(filePath, ciFile.fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
try {
|
||||
decryptCryptoFile(filePath, ciFile.fileSource.cryptoArgs, tmpFile.absolutePath)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to decrypt crypto file: " + e.stackTraceToString())
|
||||
return@createTmpFileAndDelete
|
||||
}
|
||||
tmpFile.inputStream().use { it.copyTo(outputStream) }
|
||||
showToast(generalGetString(MR.strings.image_saved))
|
||||
}
|
||||
outputStream.close()
|
||||
} else {
|
||||
File(filePath).inputStream().use { it.copyTo(outputStream) }
|
||||
outputStream.close()
|
||||
showToast(generalGetString(MR.strings.image_saved))
|
||||
}
|
||||
showToast(generalGetString(MR.strings.image_saved))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user