forked from GitHub-Mirror/riotX-android
Fix bug
This commit is contained in:
parent
d7b2371854
commit
058e7153a1
@ -62,11 +62,9 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||
val folder = getFolder(downloadMode, id)
|
||||
|
||||
File(folder, fileName)
|
||||
}.map { destFile ->
|
||||
if (!destFile.exists()) {
|
||||
}.flatMap { destFile ->
|
||||
if (!destFile.exists() || downloadMode == FileService.DownloadMode.TO_EXPORT) {
|
||||
Try {
|
||||
Timber.v("## decrypt file")
|
||||
|
||||
val resolvedUrl = contentUrlResolver.resolveFullSize(url) ?: throw IllegalArgumentException("url is null")
|
||||
|
||||
val request = Request.Builder()
|
||||
@ -82,6 +80,7 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||
}
|
||||
|
||||
if (elementToDecrypt != null) {
|
||||
Timber.v("## decrypt file")
|
||||
MXEncryptedAttachments.decryptAttachment(inputStream, elementToDecrypt) ?: throw IllegalStateException("Decryption error")
|
||||
} else {
|
||||
inputStream
|
||||
@ -89,10 +88,11 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||
}
|
||||
.map { inputStream ->
|
||||
writeToFile(inputStream, destFile)
|
||||
destFile
|
||||
}
|
||||
} else {
|
||||
Try.just(destFile)
|
||||
}
|
||||
|
||||
destFile
|
||||
}
|
||||
}
|
||||
.foldToCallback(callback)
|
||||
|
@ -452,7 +452,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||
FileService.DownloadMode.TO_EXPORT,
|
||||
action.eventId,
|
||||
action.messageFileContent.getFileName(),
|
||||
action.messageFileContent.url,
|
||||
action.messageFileContent.encryptedFileInfo?.url ?: action.messageFileContent.url,
|
||||
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||
object : MatrixCallback<File> {
|
||||
override fun onSuccess(data: File) {
|
||||
|
Loading…
Reference in New Issue
Block a user