Avoid logboog to grow too much

This commit is contained in:
2024-11-22 07:00:00 +01:00
parent c6b5ec1a4d
commit 653c57e6e0
5 changed files with 80 additions and 5 deletions

View File

@@ -1,5 +1,19 @@
package it.danieleverducci.lunatracker.entities
class Logbook {
companion object {
val MAX_SAFE_LOGBOOK_SIZE = 30000
}
val logs = ArrayList<LunaEvent>()
fun isTooBig(): Boolean {
return logs.size > MAX_SAFE_LOGBOOK_SIZE
}
/**
* Halves the logbook to avoid the file being too big
*/
fun trim() {
logs.subList(MAX_SAFE_LOGBOOK_SIZE/2, logs.size).clear()
}
}