Fix file export when no file can open this type and export is chosen

Before the `FileInputStream` got closed before started reading because of the async UseCase
This commit is contained in:
Julian Raufelder 2022-05-05 17:44:36 +02:00
parent 0f05400353
commit 47131abd50
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D

View File

@ -284,16 +284,18 @@ class BrowseFilesPresenter @Inject constructor( //
private fun copyFile(downloadFiles: List<DownloadFile>) { private fun copyFile(downloadFiles: List<DownloadFile>) {
downloadFiles.forEach { downloadFile -> downloadFiles.forEach { downloadFile ->
try { try {
FileInputStream(fileUtil.fileFor(cloudFileModelMapper.toModel(downloadFile.downloadFile))).use { val source = FileInputStream(fileUtil.fileFor(cloudFileModelMapper.toModel(downloadFile.downloadFile)))
copyDataUseCase // copyDataUseCase //
.withSource(it) // .withSource(source) //
.andTarget(downloadFile.dataSink) // .andTarget(downloadFile.dataSink) //
.run(object : DefaultResultHandler<Void>() { .run(object : DefaultResultHandler<Void>() {
override fun onFinished() { override fun onSuccess(t: Void?) {
view?.showMessage(R.string.screen_file_browser_msg_file_exported) view?.showMessage(R.string.screen_file_browser_msg_file_exported)
} }
}) override fun onFinished() {
} source.close()
}
})
} catch (e: FileNotFoundException) { } catch (e: FileNotFoundException) {
showError(e) showError(e)
} }