From e893e6d84fa65532ca6212addaea9855edf899d1 Mon Sep 17 00:00:00 2001 From: F0x1d Date: Sun, 8 Feb 2026 23:59:46 +0300 Subject: [PATCH] fix: save all logs feature --- .../feature/logging/impl/data/LoggingRepositoryImpl.kt | 6 +++++- .../recordings/impl/data/RecordingsRepositoryImpl.kt | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/feature/logging/impl/src/main/kotlin/com/f0x1d/logfox/feature/logging/impl/data/LoggingRepositoryImpl.kt b/feature/logging/impl/src/main/kotlin/com/f0x1d/logfox/feature/logging/impl/data/LoggingRepositoryImpl.kt index 68553069..3c9aa8e0 100644 --- a/feature/logging/impl/src/main/kotlin/com/f0x1d/logfox/feature/logging/impl/data/LoggingRepositoryImpl.kt +++ b/feature/logging/impl/src/main/kotlin/com/f0x1d/logfox/feature/logging/impl/data/LoggingRepositoryImpl.kt @@ -17,6 +17,7 @@ import kotlinx.coroutines.withTimeout import timber.log.Timber import java.io.BufferedReader import javax.inject.Inject +import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds internal class LoggingRepositoryImpl @Inject constructor( @@ -42,6 +43,7 @@ internal class LoggingRepositoryImpl @Inject constructor( terminal = terminal, command = command, startingId = startingId, + readLineTimeout = 10.seconds, ) }.flowOn(ioDispatcher) @@ -52,6 +54,7 @@ internal class LoggingRepositoryImpl @Inject constructor( terminal = terminal, command = command, startingId = 0, + readLineTimeout = 1.seconds, ) }.flowOn(ioDispatcher) @@ -59,6 +62,7 @@ internal class LoggingRepositoryImpl @Inject constructor( terminal: Terminal, command: Array, startingId: Long, + readLineTimeout: Duration, ) { if (terminal.isSupported().not()) { Timber.d("Terminal $terminal is not supported") @@ -79,7 +83,7 @@ internal class LoggingRepositoryImpl @Inject constructor( while (true) { Timber.d("Started awaiting line") - val line = withTimeout(10.seconds) { + val line = withTimeout(readLineTimeout) { reader.readLineCancellable() } Timber.d("Got line $line") diff --git a/feature/recordings/impl/src/main/kotlin/com/f0x1d/logfox/feature/recordings/impl/data/RecordingsRepositoryImpl.kt b/feature/recordings/impl/src/main/kotlin/com/f0x1d/logfox/feature/recordings/impl/data/RecordingsRepositoryImpl.kt index ea81deb6..7f2a597a 100644 --- a/feature/recordings/impl/src/main/kotlin/com/f0x1d/logfox/feature/recordings/impl/data/RecordingsRepositoryImpl.kt +++ b/feature/recordings/impl/src/main/kotlin/com/f0x1d/logfox/feature/recordings/impl/data/RecordingsRepositoryImpl.kt @@ -19,6 +19,7 @@ import com.f0x1d.logfox.feature.terminals.api.base.Terminal import com.f0x1d.logfox.feature.terminals.api.base.TerminalType import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flowOn @@ -82,6 +83,8 @@ internal class RecordingsRepositoryImpl @Inject constructor( context.toast(Strings.error_saving_logs) } e.printStackTrace() + } catch (_: TimeoutCancellationException) { + // Collection of logs finished! } LogRecording(