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)
|
val folder = getFolder(downloadMode, id)
|
||||||
|
|
||||||
File(folder, fileName)
|
File(folder, fileName)
|
||||||
}.map { destFile ->
|
}.flatMap { destFile ->
|
||||||
if (!destFile.exists()) {
|
if (!destFile.exists() || downloadMode == FileService.DownloadMode.TO_EXPORT) {
|
||||||
Try {
|
Try {
|
||||||
Timber.v("## decrypt file")
|
|
||||||
|
|
||||||
val resolvedUrl = contentUrlResolver.resolveFullSize(url) ?: throw IllegalArgumentException("url is null")
|
val resolvedUrl = contentUrlResolver.resolveFullSize(url) ?: throw IllegalArgumentException("url is null")
|
||||||
|
|
||||||
val request = Request.Builder()
|
val request = Request.Builder()
|
||||||
|
@ -82,6 +80,7 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementToDecrypt != null) {
|
if (elementToDecrypt != null) {
|
||||||
|
Timber.v("## decrypt file")
|
||||||
MXEncryptedAttachments.decryptAttachment(inputStream, elementToDecrypt) ?: throw IllegalStateException("Decryption error")
|
MXEncryptedAttachments.decryptAttachment(inputStream, elementToDecrypt) ?: throw IllegalStateException("Decryption error")
|
||||||
} else {
|
} else {
|
||||||
inputStream
|
inputStream
|
||||||
|
@ -89,11 +88,12 @@ internal class DefaultFileService @Inject constructor(private val context: Conte
|
||||||
}
|
}
|
||||||
.map { inputStream ->
|
.map { inputStream ->
|
||||||
writeToFile(inputStream, destFile)
|
writeToFile(inputStream, destFile)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destFile
|
destFile
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Try.just(destFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.foldToCallback(callback)
|
.foldToCallback(callback)
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,7 +452,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
FileService.DownloadMode.TO_EXPORT,
|
FileService.DownloadMode.TO_EXPORT,
|
||||||
action.eventId,
|
action.eventId,
|
||||||
action.messageFileContent.getFileName(),
|
action.messageFileContent.getFileName(),
|
||||||
action.messageFileContent.url,
|
action.messageFileContent.encryptedFileInfo?.url ?: action.messageFileContent.url,
|
||||||
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
action.messageFileContent.encryptedFileInfo?.toElementToDecrypt(),
|
||||||
object : MatrixCallback<File> {
|
object : MatrixCallback<File> {
|
||||||
override fun onSuccess(data: File) {
|
override fun onSuccess(data: File) {
|
||||||
|
|
Loading…
Reference in New Issue