mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
fix: reduce attempts for downloading image, invert unreachable type check
This commit is contained in:
parent
77ee554450
commit
b5eaed3cbb
@ -446,8 +446,8 @@ object OnionRequestAPI {
|
||||
val payloadData = JsonUtil.toJson(payload).toByteArray()
|
||||
return sendOnionRequest(Destination.Snode(snode), payloadData, version).recover { exception ->
|
||||
val error = when (exception) {
|
||||
is HTTP.HTTPRequestFailedException -> SnodeAPI.handleSnodeError(exception.statusCode, exception.json, snode, publicKey)
|
||||
is HTTPRequestFailedAtDestinationException -> SnodeAPI.handleSnodeError(exception.statusCode, exception.json, snode, publicKey)
|
||||
is HTTP.HTTPRequestFailedException -> SnodeAPI.handleSnodeError(exception.statusCode, exception.json, snode, publicKey)
|
||||
else -> null
|
||||
}
|
||||
if (error != null) { throw error }
|
||||
|
@ -4,7 +4,9 @@ import okhttp3.HttpUrl
|
||||
import org.session.libsession.messaging.file_server.FileServerApi
|
||||
import org.session.libsignal.utilities.HTTP
|
||||
import org.session.libsignal.utilities.Log
|
||||
import java.io.*
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
|
||||
object DownloadUtilities {
|
||||
|
||||
@ -14,7 +16,7 @@ object DownloadUtilities {
|
||||
@JvmStatic
|
||||
fun downloadFile(destination: File, url: String) {
|
||||
val outputStream = FileOutputStream(destination) // Throws
|
||||
var remainingAttempts = 4
|
||||
var remainingAttempts = 2
|
||||
var exception: Exception? = null
|
||||
while (remainingAttempts > 0) {
|
||||
remainingAttempts -= 1
|
||||
|
Loading…
Reference in New Issue
Block a user