add autostop on strategy testing error

This commit is contained in:
white
2025-12-08 12:07:38 +03:00
parent 87a9740aad
commit 77823252f2

View File

@@ -122,16 +122,20 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
}
suspend fun performTest() {
val targets = readActiveListsLines()
var stopTest : Boolean = false;
for (index in strategyStates.indices) {
val current = strategyStates[index]
if (stopTest) break
strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing)
enableStrategy(current.path, prefs)
if (prefs.getBoolean("use_module", false)) {
getStatus { if (it) stopService { error ->
_errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
} }
startService { error ->
_errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
}
try {
val progress = countReachable(index, targets)
@@ -143,6 +147,7 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
} finally {
stopService { error ->
_errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
}
disableStrategy(current.path, prefs)
}