Ensure that deleteAllFiles will check all the log files.
This commit is contained in:
parent
18c325560b
commit
2a4fc974ea
1 changed files with 16 additions and 3 deletions
|
|
@ -326,9 +326,22 @@ class DefaultBugReporter @Inject constructor(
|
|||
|
||||
suspend fun deleteAllFiles(predicate: (File) -> Boolean) {
|
||||
withContext(coroutineDispatchers.io) {
|
||||
getLogFiles()
|
||||
.filter(predicate)
|
||||
.forEach { it.safeDelete() }
|
||||
deleteAllFilesRecursive(baseLogDirectory, predicate)
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteAllFilesRecursive(
|
||||
directory: File,
|
||||
predicate: (File) -> Boolean,
|
||||
) {
|
||||
directory.listFiles()?.forEach { file ->
|
||||
if (file.isDirectory) {
|
||||
deleteAllFilesRecursive(file, predicate)
|
||||
} else {
|
||||
if (predicate(file)) {
|
||||
file.safeDelete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue