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

IO: Improve debug logging #1410

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.darken.sdmse.common.files

import eu.darken.sdmse.common.debug.logging.Logging.Priority.VERBOSE
import eu.darken.sdmse.common.debug.logging.Logging.Priority.WARN
import eu.darken.sdmse.common.debug.logging.log
import eu.darken.sdmse.common.files.local.LocalPath
import eu.darken.sdmse.common.files.local.crumbsTo
Expand Down Expand Up @@ -118,19 +119,26 @@ suspend fun <T : APath> T.deleteAll(
filter: (APathLookup<*>) -> Boolean = { true }
) {
try {
// Recursion enter
val lookup = gateway.lookup(this)

if (lookup.isDirectory) {
gateway.listFiles(this).forEach { it.deleteAll(gateway, filter) }
gateway.listFiles(this).forEach {
it.deleteAll(gateway, filter) // Recursion enter
}
}

if (!filter(lookup)) {
log(VERBOSE) { "Skipped due to filter: $this" }
return
}
} catch (e: ReadException) {
if (!gateway.exists(this)) return else throw e
} catch (e: PathException) {
val exists = gateway.exists(this)
if (!exists) {
log(WARN) { "Path failed to delete, but no longer exists: $this" }
return
} else {
throw e
}
}

// Recursion exit
Expand Down
Loading