mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Ensure that deleteAllFiles will check all the log files.
This commit is contained in:
+16
-3
@@ -326,9 +326,22 @@ class DefaultBugReporter @Inject constructor(
|
|||||||
|
|
||||||
suspend fun deleteAllFiles(predicate: (File) -> Boolean) {
|
suspend fun deleteAllFiles(predicate: (File) -> Boolean) {
|
||||||
withContext(coroutineDispatchers.io) {
|
withContext(coroutineDispatchers.io) {
|
||||||
getLogFiles()
|
deleteAllFilesRecursive(baseLogDirectory, predicate)
|
||||||
.filter(predicate)
|
}
|
||||||
.forEach { it.safeDelete() }
|
}
|
||||||
|
|
||||||
|
private fun deleteAllFilesRecursive(
|
||||||
|
directory: File,
|
||||||
|
predicate: (File) -> Boolean,
|
||||||
|
) {
|
||||||
|
directory.listFiles()?.forEach { file ->
|
||||||
|
if (file.isDirectory) {
|
||||||
|
deleteAllFilesRecursive(file, predicate)
|
||||||
|
} else {
|
||||||
|
if (predicate(file)) {
|
||||||
|
file.safeDelete()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user