MaintenancePlugin add cleaning of old dedicated autotune log file

This commit is contained in:
Philoul 2022-05-05 13:23:10 +02:00
parent d8762bec0f
commit 50d60e1302

View file

@ -69,11 +69,24 @@ class MaintenancePlugin @Inject constructor(
val files = logDir.listFiles { _: File?, name: String ->
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))
}
val autotunefiles = logDir.listFiles { _: File?, name: String ->
(name.startsWith("autotune") && name.endsWith(".zip"))
}
val amount = sp.getInt(R.string.key_logshipper_amount, keep)
val keepIndex = amount - 1
if (autotunefiles != null && autotunefiles.isNotEmpty()) {
Arrays.sort(autotunefiles) { f1: File, f2: File -> f2.name.compareTo(f1.name) }
var delAutotuneFiles = listOf(*autotunefiles)
if (keepIndex < delAutotuneFiles.size) {
delAutotuneFiles = delAutotuneFiles.subList(keepIndex, delAutotuneFiles.size)
for (file in delAutotuneFiles) {
file.delete()
}
}
}
if (files == null || files.isEmpty()) return
Arrays.sort(files) { f1: File, f2: File -> f2.name.compareTo(f1.name) }
var delFiles = listOf(*files)
val amount = sp.getInt(R.string.key_logshipper_amount, keep)
val keepIndex = amount - 1
if (keepIndex < delFiles.size) {
delFiles = delFiles.subList(keepIndex, delFiles.size)
for (file in delFiles) {