From 94a0bca2508bb18b413eca8bccb2e95c41091a44 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 6 Jun 2024 12:54:10 +0200 Subject: [PATCH] Fixed LXMF delivery limits not getting updated until restart --- sbapp/sideband/core.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 7668fa6..6e87779 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -133,6 +133,7 @@ class SidebandCore(): self.telemetry_send_blocked_until = 0 self.pending_telemetry_request = False self.telemetry_request_max_history = 7*24*60*60 + self.default_lxm_limit = 128*1000 self.state_db = {} self.state_lock = Lock() self.rpc_connection = None @@ -2641,6 +2642,19 @@ class SidebandCore(): RNS.log("Error while querying for key: "+str(e), RNS.LOG_ERROR) return False + def _update_delivery_limits(self): + try: + if self.config["lxm_limit_1mb"]: + lxm_limit = 1000 + else: + lxm_limit = self.default_lxm_limit + if self.message_router.delivery_per_transfer_limit != lxm_limit: + self.message_router.delivery_per_transfer_limit = lxm_limit + RNS.log("Updated delivery limit to "+RNS.prettysize(self.message_router.delivery_per_transfer_limit*1000), RNS.LOG_DEBUG) + + except Exception as e: + RNS.log("Error while updating LXMF router delivery limit: "+str(e), RNS.LOG_ERROR) + def _service_jobs(self): if self.is_service: last_usb_discovery = time.time() @@ -2835,6 +2849,8 @@ class SidebandCore(): if self.owner_service != None: self.owner_service.update_location_provider() + self._update_delivery_limits() + if self.config["lxmf_periodic_sync"] == True: if self.getpersistent("lxmf.lastsync") == None: self.setpersistent("lxmf.lastsync", time.time()) @@ -3374,7 +3390,7 @@ class SidebandCore(): if self.config["lxm_limit_1mb"]: lxm_limit = 1000 else: - lxm_limit = 128*1000 + lxm_limit = self.default_lxm_limit self.message_router = LXMF.LXMRouter(identity = self.identity, storagepath = self.lxmf_storage, autopeer = True, delivery_limit = lxm_limit) self.message_router.register_delivery_callback(self.lxmf_delivery)