Fix crash reported by rageshake: writeToFile may throw exceptions

This commit is contained in:
Benoit Marty 2019-12-17 12:26:45 +01:00
parent 1c727c1ee4
commit 42cdb1db11
1 changed files with 5 additions and 7 deletions

View File

@ -83,15 +83,13 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
if (elementToDecrypt != null) { if (elementToDecrypt != null) {
Timber.v("## decrypt file") Timber.v("## decrypt file")
MXEncryptedAttachments.decryptAttachment(inputStream, elementToDecrypt) ?: throw IllegalStateException("Decryption error") MXEncryptedAttachments.decryptAttachment(inputStream, elementToDecrypt)
} else { ?: throw IllegalStateException("Decryption error")
inputStream
} }
writeToFile(inputStream, destFile)
destFile
} }
.map { inputStream ->
writeToFile(inputStream, destFile)
destFile
}
} else { } else {
Try.just(destFile) Try.just(destFile)
} }