srctree

Robin Linden parent d97c04e9 ed6eae25
Propagate errors from file chunk sending

inlinesplit
domain/src/main/kotlin/tox/Tox.kt added: 10, removed: 6, total 4
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2019-2021 aTox contributors
// SPDX-FileCopyrightText: 2019-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2019-2020 aTox contributors
//
// SPDX-License-Identifier: GPL-3.0-only
 
@@ -174,7 +175,8 @@ class Tox @Inject constructor(
fun sendFile(pk: PublicKey, fileKind: FileKind, fileSize: Long, fileName: String) =
tox.sendFile(pk, fileKind, fileSize, fileName)
 
fun sendFileChunk(pk: PublicKey, fileNo: Int, pos: Long, data: ByteArray) = tox.sendFileChunk(pk, fileNo, pos, data)
fun sendFileChunk(pk: PublicKey, fileNo: Int, pos: Long, data: ByteArray): Result<Unit> =
tox.sendFileChunk(pk, fileNo, pos, data)
 
fun getName() = tox.getName()
fun setName(name: String) {
 
domain/src/main/kotlin/tox/ToxWrapper.kt added: 10, removed: 6, total 4
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2021 aTox contributors
// SPDX-FileCopyrightText: 2019-2023 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: GPL-3.0-only
 
@@ -146,10 +146,12 @@ class ToxWrapper(
Log.e(TAG, "Error sending ft $fileName ${pk.fingerprint()}\n$e")
}
 
fun sendFileChunk(pk: PublicKey, fileNo: Int, pos: Long, data: ByteArray) = try {
fun sendFileChunk(pk: PublicKey, fileNo: Int, pos: Long, data: ByteArray): Result<Unit> = try {
tox.fileSendChunk(contactByKey(pk), fileNo, pos, data)
Result.success(Unit)
} catch (e: ToxFileSendChunkException) {
Log.e(TAG, "Error sending chunk $pos:${data.size} to ${pk.fingerprint()} $fileNo\n$e")
Result.failure(e)
}
 
fun setTyping(publicKey: PublicKey, typing: Boolean) = tox.setTyping(contactByKey(publicKey), typing)