mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix(meshlog): Change default retention to 30 days (#4177)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
63318bf66e
commit
399dce19a6
5 changed files with 10 additions and 42 deletions
|
|
@ -20,8 +20,6 @@ import android.app.Application
|
|||
import androidx.hilt.work.HiltWorkerFactory
|
||||
import androidx.work.Configuration
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import androidx.work.ExistingWorkPolicy
|
||||
import androidx.work.OneTimeWorkRequestBuilder
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import co.touchlab.kermit.Logger
|
||||
|
|
@ -59,7 +57,6 @@ class MeshUtilApplication :
|
|||
|
||||
// Schedule periodic MeshLog cleanup
|
||||
scheduleMeshLogCleanup()
|
||||
enqueueImmediateCleanupIfNeeded()
|
||||
|
||||
// Initialize DatabaseManager asynchronously with current device address so DAO consumers have an active DB
|
||||
val entryPoint = EntryPointAccessors.fromApplication(this, AppEntryPoint::class.java)
|
||||
|
|
@ -84,27 +81,6 @@ class MeshUtilApplication :
|
|||
)
|
||||
}
|
||||
|
||||
private fun enqueueImmediateCleanupIfNeeded() {
|
||||
// Use entry point to access prefs outside of Hilt graph
|
||||
val entryPoint = EntryPointAccessors.fromApplication(this, AppEntryPoint::class.java)
|
||||
val meshLogPrefs = entryPoint.meshLogPrefs()
|
||||
val retentionDays = meshLogPrefs.retentionDays
|
||||
if (!meshLogPrefs.loggingEnabled || retentionDays == MeshLogPrefs.NEVER_CLEAR_RETENTION_DAYS) {
|
||||
Logger.i {
|
||||
"Skipping immediate MeshLog cleanup; " +
|
||||
"loggingEnabled=${meshLogPrefs.loggingEnabled}, retention=$retentionDays"
|
||||
}
|
||||
return
|
||||
}
|
||||
Logger.i { "Enqueuing immediate MeshLog cleanup with retentionDays=$retentionDays" }
|
||||
WorkManager.getInstance(this)
|
||||
.enqueueUniqueWork(
|
||||
"${MeshLogCleanupWorker.WORK_NAME}_immediate",
|
||||
ExistingWorkPolicy.REPLACE,
|
||||
OneTimeWorkRequestBuilder<MeshLogCleanupWorker>().build(),
|
||||
)
|
||||
}
|
||||
|
||||
override val workManagerConfiguration: Configuration
|
||||
get() = Configuration.Builder().setWorkerFactory(workerFactory).build()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue