Added error handling to config reload

This commit is contained in:
Mark Qvist 2023-11-01 02:38:23 +01:00
parent 10273d3e85
commit bf74698058

View File

@ -612,11 +612,16 @@ class SidebandCore():
def __reload_config(self):
RNS.log("Reloading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
config_file = open(self.config_path, "rb")
self.config = msgpack.unpackb(config_file.read())
config_file.close()
with open(self.config_path, "rb") as config_file:
config_data = config_file.read()
try:
unpacked_config = msgpack.unpackb(config_data)
if unpacked_config != None and len(unpacked_config) != 0:
self.config = unpacked_config
self.update_active_lxmf_propagation_node()
except Exception as e:
RNS.log("Error while reloading configuration: "+str(e), RNS.LOG_ERROR)
def __save_config(self):
RNS.log("Saving Sideband configuration...", RNS.LOG_DEBUG)