Merge pull request #1230 from vector-im/feature/fix_download_file

Catch network errors during file downloading.
This commit is contained in:
Benoit Marty 2020-04-15 16:54:31 +02:00 committed by GitHub
commit dcfbfc4981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -28,6 +28,7 @@ Bugfix 🐛:
- Cross- Signing | After signin in new session, verification paper trail in DM is off (#1191)
- Failed to encrypt message in room (message stays in red), [thanks to pwr22] (#925)
- Cross-Signing | web <-> riotX After QR code scan, gossiping fails (#1210)
- Fix crash when trying to download file without internet connection (#1229)
- Local echo are not updated in timeline (for failed & encrypted states)
Translations 🗣:

View File

@ -79,9 +79,15 @@ internal class DefaultFileService @Inject constructor(
.url(resolvedUrl)
.build()
val response = okHttpClient.newCall(request).execute()
val response = try {
okHttpClient.newCall(request).execute()
} catch (e: Throwable) {
return@flatMap Try.Failure(e)
}
var inputStream = response.body?.byteStream()
Timber.v("Response size ${response.body?.contentLength()} - Stream available: ${inputStream?.available()}")
if (!response.isSuccessful || inputStream == null) {
return@flatMap Try.Failure(IOException())
}