Add an application migration to delete the old log files.
This commit is contained in:
parent
9bce1156f2
commit
76e34ae798
6 changed files with 96 additions and 9 deletions
|
|
@ -20,13 +20,14 @@ import com.squareup.anvil.annotations.ContributesBinding
|
|||
import io.element.android.features.rageshake.api.logs.LogFilesRemover
|
||||
import io.element.android.features.rageshake.impl.reporter.DefaultBugReporter
|
||||
import io.element.android.libraries.di.AppScope
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
class DefaultLogFilesRemover @Inject constructor(
|
||||
private val bugReporter: DefaultBugReporter,
|
||||
) : LogFilesRemover {
|
||||
override suspend fun perform() {
|
||||
bugReporter.deleteAllFiles()
|
||||
override suspend fun perform(predicate: (File) -> Boolean) {
|
||||
bugReporter.deleteAllFiles(predicate)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,9 +301,11 @@ class DefaultBugReporter @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun deleteAllFiles() {
|
||||
suspend fun deleteAllFiles(predicate: (File) -> Boolean) {
|
||||
withContext(coroutineDispatchers.io) {
|
||||
getLogFiles().forEach { it.safeDelete() }
|
||||
getLogFiles()
|
||||
.filter(predicate)
|
||||
.forEach { it.safeDelete() }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue