- storage fix (new key)

This commit is contained in:
Andy Rozman 2021-06-11 15:57:14 +01:00
parent 6fd1a8bd8d
commit 95326a2894
2 changed files with 15 additions and 1 deletions

View file

@ -8,8 +8,8 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.interfaces.PluginType
@ -67,6 +67,10 @@ class MaintenancePlugin @Inject constructor(
//todo replace this with a call on startup of the application, specifically to remove
// unnecessary garbage from the log exports
fun deleteLogs(keep: Int) {
if (true)
return
val logDir = File(loggerUtils.logDirectory)
val files = logDir.listFiles { _: File?, name: String ->
(name.startsWith("AndroidAPS") && name.endsWith(".zip"))

View file

@ -32,6 +32,7 @@ class PumpSyncStorage @Inject constructor(
init {
initStorage()
cleanOldStorage();
}
fun initStorage() {
@ -66,6 +67,15 @@ class PumpSyncStorage @Inject constructor(
}
}
fun cleanOldStorage(): Unit {
val oldSpKeys = setOf("pump_sync_storage", "pump_sync_storage_xstream")
for (oldSpKey in oldSpKeys) {
if (sp.contains(oldSpKey))
sp.remove(oldSpKey)
}
}
fun isStorageEmpty(): Boolean {
return pumpSyncStorage[BOLUS]!!.isEmpty() && pumpSyncStorage[TBR]!!.isEmpty()
}