Skip to content

Commit

Permalink
AppCleaner: Better deletion progress feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Nov 28, 2024
1 parent c396768 commit 21259dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/main/java/eu/darken/sdmse/appcleaner/core/AppCleaner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import javax.inject.Inject
Expand Down Expand Up @@ -231,11 +232,16 @@ class AppCleaner @Inject constructor(
?: throw IllegalStateException("Can't find filter for $filterIdentifier")

updateProgressSecondary(eu.darken.sdmse.common.R.string.general_progress_loading)

val currentProgress = progress.first()
filter.withProgress(
client = this,
onUpdate = { old, new -> old?.copy(secondary = new?.primary ?: CaString.EMPTY) },
onCompletion = { it }
onUpdate = { old, new ->
old?.copy(
secondary = new?.primary ?: CaString.EMPTY,
count = new?.count ?: Progress.Count.Indeterminate(),
)
},
onCompletion = { currentProgress }
) {
val result = process(targets, allMatches)
log(TAG, INFO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ abstract class BaseExpendablesFilter : ExpendablesFilter {
val successful = mutableSetOf<ExpendablesFilter.Match>()
val failed = mutableSetOf<Pair<ExpendablesFilter.Match, Exception>>()

log(TAG, VERBOSE) { "Checking distinct roots..." }
val distinctRoots = targets.map { it.lookup }.filterDistinctRoots()

if (distinctRoots.size != targets.size) {
Expand All @@ -52,9 +53,11 @@ abstract class BaseExpendablesFilter : ExpendablesFilter {
}
}

log(TAG) { "Got ${distinctRoots.size} distinct roots" }
updateProgressCount(Progress.Count.Percent(distinctRoots.size))

distinctRoots.forEach { targetRoot ->
log(TAG) { "Processing root: $targetRoot" }
updateProgressPrimary(targetRoot.userReadablePath)
val main = targets.first { it.lookup == targetRoot }

Expand Down

0 comments on commit 21259dd

Please sign in to comment.