Skip to content

Commit

Permalink
SystemCleaner: Add default exclusion for /data/rootfs
Browse files Browse the repository at this point in the history
This is not a common folder or one that has many (or any?) legit targets.

Edge cases where is desired to be scanned can just remove the default exclusion.

Fixes #1331
  • Loading branch information
d4rken committed Jul 31, 2024
1 parent 52b69ae commit 6605218
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import eu.darken.sdmse.common.datastore.value
import eu.darken.sdmse.common.debug.logging.Logging.Priority.INFO
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.debug.logging.logTag
import eu.darken.sdmse.common.files.local.LocalPath
import eu.darken.sdmse.common.pkgs.toPkgId
import eu.darken.sdmse.exclusion.core.types.DefaultExclusion
import eu.darken.sdmse.exclusion.core.types.Exclusion
import eu.darken.sdmse.exclusion.core.types.ExclusionId
import eu.darken.sdmse.exclusion.core.types.PathExclusion
import eu.darken.sdmse.exclusion.core.types.PkgExclusion
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -47,7 +49,11 @@ class DefaultExclusions @Inject constructor(
DefaultExclusion(
"https://github.com/d4rken-org/sdmaid-se/issues/618",
PkgExclusion("de.zollsoft.impfapp".toPkgId(), setOf(Exclusion.Tag.APPCLEANER)),
)
),
DefaultExclusion(
"https://github.com/d4rken-org/sdmaid-se/issues/1331",
PathExclusion(LocalPath.build("data", "rootfs"), setOf(Exclusion.Tag.SYSTEMCLEANER)),
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SystemCrawler @Inject constructor(
updateProgressCount(Progress.Count.Indeterminate())

val exclusions = exclusionManager.pathExclusions(SDMTool.Type.SYSTEMCLEANER)

log(TAG, INFO) { "Loaded exclusions: $exclusions" }

val currentAreas = areaManager.currentAreas()
val targetAreas = filters
Expand Down Expand Up @@ -104,16 +104,25 @@ class SystemCrawler @Inject constructor(
.flatMapMerge(3) { area ->
val filter: suspend (APathLookup<*>) -> Boolean = when (area.type) {
DataArea.Type.SDCARD -> filter@{ toCheck: APathLookup<*> ->
if (sdcardSkips.any { toCheck.segments.endsWith(it) }) return@filter false
exclusions.none { it.match(toCheck) }
if (sdcardSkips.any { toCheck.segments.endsWith(it) }) {
log(TAG, INFO) { "Excluded $toCheck by global skip" }
return@filter false
}

exclusions.none { excl ->
excl.match(toCheck).also { if (it) log(TAG, INFO) { "Excluded $toCheck by $excl" } }
}
}

else -> filter@{ toCheck: APathLookup<*> ->
if (globalSkips.any { toCheck.segments.startsWith(it) }) {
log(TAG, WARN) { "Skipping: $toCheck" }
log(TAG, INFO) { "Excluded $toCheck by global skip" }
return@filter false
}
exclusions.none { it.match(toCheck) }

exclusions.none { excl ->
excl.match(toCheck).also { if (it) log(TAG, INFO) { "Excluded $toCheck by $excl" } }
}
}
}
area.path.walk(
Expand Down

0 comments on commit 6605218

Please sign in to comment.