fix NPE
This commit is contained in:
parent
2a8f9bd7d3
commit
74ca36bb6e
2 changed files with 23 additions and 22 deletions
|
@ -63,31 +63,31 @@ class MaintenancePlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo replace this with a call on startup of the application, specifically to remove
|
//todo replace this with a call on startup of the application, specifically to remove
|
||||||
// unnecessary garbage from the log exports
|
// unnecessary garbage from the log exports
|
||||||
fun deleteLogs() {
|
fun deleteLogs() {
|
||||||
val logDirectory = LoggerUtils.getLogDirectory()
|
LoggerUtils.getLogDirectory()?.let { logDirectory ->
|
||||||
val logDir = File(logDirectory)
|
val logDir = File(logDirectory)
|
||||||
val files = logDir.listFiles { _: File?, name: String ->
|
val files = logDir.listFiles { _: File?, name: String ->
|
||||||
(name.startsWith("AndroidAPS")
|
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))
|
||||||
&& name.endsWith(".zip"))
|
|
||||||
}
|
|
||||||
Arrays.sort(files) { f1: File, f2: File -> f1.name.compareTo(f2.name) }
|
|
||||||
var delFiles = listOf(*files)
|
|
||||||
val amount = sp.getInt(R.string.key_logshipper_amount, 2)
|
|
||||||
val keepIndex = amount - 1
|
|
||||||
if (keepIndex < delFiles.size) {
|
|
||||||
delFiles = delFiles.subList(keepIndex, delFiles.size)
|
|
||||||
for (file in delFiles) {
|
|
||||||
file.delete()
|
|
||||||
}
|
}
|
||||||
}
|
Arrays.sort(files) { f1: File, f2: File -> f1.name.compareTo(f2.name) }
|
||||||
val exportDir = File(logDirectory, "exports")
|
var delFiles = listOf(*files)
|
||||||
if (exportDir.exists()) {
|
val amount = sp.getInt(R.string.key_logshipper_amount, 2)
|
||||||
val expFiles = exportDir.listFiles()
|
val keepIndex = amount - 1
|
||||||
for (file in expFiles) {
|
if (keepIndex < delFiles.size) {
|
||||||
file.delete()
|
delFiles = delFiles.subList(keepIndex, delFiles.size)
|
||||||
|
for (file in delFiles) {
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val exportDir = File(logDirectory, "exports")
|
||||||
|
if (exportDir.exists()) {
|
||||||
|
val expFiles = exportDir.listFiles()
|
||||||
|
for (file in expFiles) {
|
||||||
|
file.delete()
|
||||||
|
}
|
||||||
|
exportDir.delete()
|
||||||
}
|
}
|
||||||
exportDir.delete()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CareportalEvent(NSMbg mbg) {
|
public CareportalEvent(NSMbg mbg) {
|
||||||
|
this();
|
||||||
date = mbg.date;
|
date = mbg.date;
|
||||||
eventType = MBG;
|
eventType = MBG;
|
||||||
json = mbg.json;
|
json = mbg.json;
|
||||||
|
|
Loading…
Reference in a new issue