Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ configurations.configureEach {
exclude(module = "commons-logging")
}

val canonicalVersionCode = 437
val canonicalVersionName = "1.31.0"
val canonicalVersionCode = 438
val canonicalVersionName = "1.31.1"

val postFixSize = 10
val abiPostFix = mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class OfficialCommunityRepository @Inject constructor(
)
}
}
}.onFailure {
if (it is CancellationException) throw it
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ open class PathManager @Inject constructor(
scope.launch {
_paths.drop(1).collectLatest { paths ->
if (paths.isEmpty()) storage.clearOnionRequestPaths()
else storage.setOnionRequestPaths(paths)
else {
try {
storage.setOnionRequestPaths(paths)
} catch (e: Exception) {
Log.e("Onion Request", "Failed to persist paths to storage, keeping in-memory only", e)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.session.libsession.network.snode

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
Expand Down Expand Up @@ -175,6 +176,8 @@ class SnodeDirectory @Inject constructor(
}
.result
}.onFailure { e ->
if (e is CancellationException) throw e

lastError = e
Log.w("SnodeDirectory", "Seed node failed: $target", e)
}
Expand Down Expand Up @@ -277,11 +280,17 @@ class SnodeDirectory @Inject constructor(
if (now >= last && now - last < POOL_REFRESH_INTERVAL_MS) return

scope.launch {
refreshPoolFromSnodes(
totalSnodeQueries = 3,
minAppearance = 2,
distinctQuerySubnetPrefix = 24,
)
try {
refreshPoolFromSnodes(
totalSnodeQueries = 3,
minAppearance = 2,
distinctQuerySubnetPrefix = 24,
)
} catch (e: Throwable) {
if (e is CancellationException) throw e

Log.w("SnodeDirectory", "Error refreshing snode pool", e)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class AutoRetryApiExecutor<Req, Res>(
private val actualExecutor: ApiExecutor<Req, Res>,
) : ApiExecutor<Req, Res> {
override suspend fun send(ctx: ApiExecutorContext, req: Req): Res {
val initStack = Throwable().stackTrace

var numRetried = 0
while (true) {
try {
Expand All @@ -32,7 +34,16 @@ class AutoRetryApiExecutor<Req, Res>(
Log.e(TAG, "Retrying $req $numRetried times due to error", e)
delay(numRetried * 2000L)
} else {
throw e
// If we know the error is ErrorWithFailureDecision, we can
// safely modify its stacktrace as we know that exception contains
// a cause where it can pinpoint to the direct trace of the error.
// Otherwise, we'll create a new exception to modify the stacktrace, so to
// preserve the original error's stacktrace which may contain important
// information about the error.

val errorToUpdateStack = e.takeIf { it is ErrorWithFailureDecision } ?: RuntimeException(e)
errorToUpdateStack.stackTrace = initStack
throw errorToUpdateStack
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.configs

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -323,10 +324,19 @@ class ConfigToDatabaseSync @Inject constructor(
messageHashes = cleanedHashes,
swarmAuth = groupAdminAuth
)
swarmApiExecutor.execute(SwarmApiRequest(
swarmPubKeyHex = groupInfoConfig.id.hexString,
api = deleteMessageApi
))

try {
swarmApiExecutor.execute(
SwarmApiRequest(
swarmPubKeyHex = groupInfoConfig.id.hexString,
api = deleteMessageApi
)
)
} catch (e: Exception) {
if (e is CancellationException) throw e

Log.e(TAG, "Failed to delete messages from swarm for group", e)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import com.google.protobuf.ByteString
import com.squareup.phrase.Phrase
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.filter
Expand Down Expand Up @@ -1225,7 +1226,12 @@ class GroupManagerV2Impl @Inject constructor(

override fun onBlocked(groupAccountId: AccountId) {
scope.launch(groupAccountId, "On blocked") {
respondToInvitation(groupAccountId, false)
try {
respondToInvitation(groupAccountId, false)
} catch (e: Throwable) {
if (e is CancellationException) throw e
Log.e(TAG, "Failed to unapprove invitation for group", e)
}

// Remove this group from config regardless
configFactory.removeGroup(groupAccountId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -107,17 +108,23 @@ class MarkReadProcessor @Inject constructor(
keySelector = { it.value.expirationInfo.expiresIn },
valueTransform = { it.key }
).forEach { (expiresIn, hashes) ->
swarmApiExecutor.execute(
SwarmApiRequest(
swarmPubKeyHex = userAuth.accountId.hexString,
api = alterTtyFactory.create(
messageHashes = hashes,
auth = userAuth,
alterType = AlterTtlApi.AlterType.Shorten,
newExpiry = snodeClock.currentTimeMillis() + expiresIn
try {
swarmApiExecutor.execute(
SwarmApiRequest(
swarmPubKeyHex = userAuth.accountId.hexString,
api = alterTtyFactory.create(
messageHashes = hashes,
auth = userAuth,
alterType = AlterTtlApi.AlterType.Shorten,
newExpiry = snodeClock.currentTimeMillis() + expiresIn
)
)
)
)
} catch (e: Throwable) {
if (e is CancellationException) throw e

Log.e(TAG, "Failed to shorten expiry for messages with hashes $hashes", e)
}
}
}
}
Expand Down