From 9541b653b5fee8c7da0d31c3b2885c38f37dab94 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Thu, 21 Mar 2024 00:01:37 +0100 Subject: [PATCH] fixed ServiceManager not loading kvstore --- src/kernel/service/ServiceManager.hx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/kernel/service/ServiceManager.hx b/src/kernel/service/ServiceManager.hx index d867f98..b45d4b1 100644 --- a/src/kernel/service/ServiceManager.hx +++ b/src/kernel/service/ServiceManager.hx @@ -17,37 +17,46 @@ class ServiceManager { /** Add a service to be automatically started. **/ - public static function enable(name:String) { + public static function enable(name:String):Outcome { if (!services.exists(name)) { - return; // Service must be started + return Failure("Service must be started before enable"); } var store = KVStore.getStoreForClass(); + store.load(); var enabled = store.get("enabled", []); enabled.push(name); store.set("enabled", enabled); store.save(); + + return Success(Noise); } /** Remove a service from being automatically started. **/ - private static function disable(name:String) { + private static function disable(name:String):Outcome { var store = KVStore.getStoreForClass(); + store.load(); + var enabled:Array = store.get("enabled"); var index = enabled.indexOf(name); if (index == -1) { - return; + return Failure("Service not found"); } enabled.splice(index, 1); store.save(); + + return Success(Noise); } private static function startAllEnabled() { var store = KVStore.getStoreForClass(); + store.load(); + var enabled:Array = store.get("enabled", []); for (name in enabled) { start(name);