Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer: Improve scan and deletion performance #1413

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions app/src/main/java/eu/darken/sdmse/analyzer/core/Analyzer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import eu.darken.sdmse.common.progress.updateProgressPrimary
import eu.darken.sdmse.common.progress.updateProgressSecondary
import eu.darken.sdmse.common.progress.withProgress
import eu.darken.sdmse.common.sharedresource.SharedResource
import eu.darken.sdmse.common.sharedresource.keepResourceHoldersAlive
import eu.darken.sdmse.common.storage.StorageId
import eu.darken.sdmse.main.core.SDMTool
import eu.darken.sdmse.setup.IncompleteSetupException
Expand Down Expand Up @@ -66,6 +67,7 @@ class Analyzer @Inject constructor(

override val type: SDMTool.Type = SDMTool.Type.ANALYZER

private val usedResources = setOf(gatewaySwitch)
override val sharedResource = SharedResource.createKeepAlive(TAG, appScope)

private val progressPub = MutableStateFlow<Progress.Data?>(null)
Expand Down Expand Up @@ -114,14 +116,15 @@ class Analyzer @Inject constructor(
log(TAG) { "submit($task) starting..." }
updateProgress { Progress.Data() }
try {
val result = when (task) {
is DeviceStorageScanTask -> scanStorageDevices(task)
is StorageScanTask -> scanStorageContents(task)
is ContentDeleteTask -> deleteContent(task)
is AppDeepScanTask -> deepScanApp(task)
else -> throw UnsupportedOperationException("Unsupported task: $task")
val result = keepResourceHoldersAlive(usedResources) {
when (task) {
is DeviceStorageScanTask -> scanStorageDevices(task)
is StorageScanTask -> scanStorageContents(task)
is ContentDeleteTask -> deleteContent(task)
is AppDeepScanTask -> deepScanApp(task)
else -> throw UnsupportedOperationException("Unsupported task: $task")
}
}

log(TAG, INFO) { "submit($task) finished: $result" }
result
} finally {
Expand Down
Loading