Skip to content

Commit

Permalink
AppCleaner: Fix duplicate paths in default caches filter
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Aug 21, 2024
1 parent 407d11c commit 489e312
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package eu.darken.sdmse.appcleaner.core

import eu.darken.sdmse.appcleaner.core.forensics.ExpendablesFilter
import eu.darken.sdmse.appcleaner.core.forensics.ExpendablesFilterIdentifier
import eu.darken.sdmse.exclusion.core.types.Exclusion
import eu.darken.sdmse.exclusion.core.types.excludeNestedLookups
import kotlin.reflect.KClass

val AppCleaner.Data?.hasData: Boolean
get() = this?.junks?.isNotEmpty() ?: false


suspend fun Collection<Exclusion.Path>.excludeNestedLookups(
matches: Collection<ExpendablesFilter.Match>
): Set<ExpendablesFilter.Match> {
Expand All @@ -16,4 +17,7 @@ suspend fun Collection<Exclusion.Path>.excludeNestedLookups(
return matches
.filter { temp.contains(it.lookup) }
.toSet()
}
}

val KClass<out ExpendablesFilter>.identifier: ExpendablesFilterIdentifier
get() = this
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import eu.darken.sdmse.appcleaner.core.AppJunk
import eu.darken.sdmse.appcleaner.core.excludeNestedLookups
import eu.darken.sdmse.appcleaner.core.forensics.ExpendablesFilter
import eu.darken.sdmse.appcleaner.core.forensics.ExpendablesFilterIdentifier
import eu.darken.sdmse.appcleaner.core.forensics.filter.DefaultCachesPrivateFilter
import eu.darken.sdmse.appcleaner.core.forensics.filter.DefaultCachesPublicFilter
import eu.darken.sdmse.appcleaner.core.identifier
import eu.darken.sdmse.common.datastore.value
import eu.darken.sdmse.common.debug.logging.Logging.Priority.INFO
import eu.darken.sdmse.common.debug.logging.Logging.Priority.VERBOSE
Expand Down Expand Up @@ -104,10 +107,16 @@ class PostProcessorModule @Inject constructor(

if (!useRoot && useShizuku) {
val edgeCaseSegs = segs(before.pkg.id.name, "cache")
before.expendables.forEach { (type, matches) ->
val edgeCases = matches.filter { it.path.segments.containsSegments(edgeCaseSegs) }
edgeCaseMap[type] = edgeCases
}
val edgeCaseFilters = setOf(
DefaultCachesPublicFilter::class.identifier,
DefaultCachesPrivateFilter::class.identifier,
)
before.expendables
.filter { edgeCaseFilters.contains(it.key) }
.forEach { (type, matches) ->
val edgeCases = matches.filter { it.path.segments.containsSegments(edgeCaseSegs) }
edgeCaseMap[type] = edgeCases
}
}

val exclusions = exclusionManager.pathExclusions(SDMTool.Type.APPCLEANER)
Expand All @@ -122,7 +131,7 @@ class PostProcessorModule @Inject constructor(
expendables = after.expendables?.mapValues { (type, paths) ->
val edges = edgeCaseMap[type] ?: emptySet()
if (edges.isNotEmpty()) log(TAG, VERBOSE) { "Re-adding edge cases: $edges" }
paths.plus(edges)
(paths + edges).toSet()
}
)

Expand Down

0 comments on commit 489e312

Please sign in to comment.