Fixed crash when downloading file once VFS is enabled
This commit is contained in:
parent
571349953b
commit
d1cbff473b
3 changed files with 6 additions and 3 deletions
|
@ -85,6 +85,8 @@ class ChatMessageContentData(
|
|||
}
|
||||
}
|
||||
|
||||
private val isEncrypted = content.isFileEncrypted
|
||||
|
||||
private val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())
|
||||
|
||||
init {
|
||||
|
@ -136,7 +138,7 @@ class ChatMessageContentData(
|
|||
scope.cancel()
|
||||
|
||||
val path = filePath.value.orEmpty()
|
||||
if (content.isFileEncrypted && path.isNotEmpty()) {
|
||||
if (path.isNotEmpty() && isEncrypted) {
|
||||
Log.i("[Content] Deleting file used for preview: $path")
|
||||
FileUtils.deleteFile(path)
|
||||
filePath.value = ""
|
||||
|
|
|
@ -74,7 +74,6 @@ class ChatMessageData(
|
|||
// TODO FIXME : find a way to refresh outgoing message downloaded
|
||||
if (state == ChatMessage.State.FileTransferDone && !message.isOutgoing) {
|
||||
Log.i("[Chat Message] File transfer done")
|
||||
contents.value.orEmpty().forEach(ChatMessageContentData::destroy)
|
||||
updateContentsList()
|
||||
|
||||
if (!message.isEphemeral && corePreferences.makePublicMediaFilesDownloaded) {
|
||||
|
|
|
@ -682,6 +682,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
private const val LINPHONE_VFS_ENCRYPTION_AES256GCM128_SHA256 = 2
|
||||
private const val VFS_IV = "vfsiv"
|
||||
private const val VFS_KEY = "vfskey"
|
||||
|
||||
@Throws(java.lang.Exception::class)
|
||||
private fun generateSecretKey() {
|
||||
val keyGenerator =
|
||||
|
@ -761,6 +762,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
Base64.decode(sharedPreferences.getString(VFS_IV, null), Base64.DEFAULT)
|
||||
)
|
||||
}
|
||||
|
||||
fun activateVFS() {
|
||||
try {
|
||||
Log.i("[Context] Activating VFS")
|
||||
|
@ -781,7 +783,7 @@ class CoreContext(val context: Context, coreConfig: Config) {
|
|||
32
|
||||
)
|
||||
|
||||
Log.i("[Context] VFS activated.")
|
||||
Log.i("[Context] VFS activated")
|
||||
} catch (e: Exception) {
|
||||
Log.f("[Context] Unable to activate VFS encryption: $e")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue