From d61f5d7c910d778e33de87b90e204bb73b6a498e Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 1 Jul 2018 04:46:37 +0200 Subject: util.pubsub: Remove node from persistent storage on deletion --- util/pubsub.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'util') diff --git a/util/pubsub.lua b/util/pubsub.lua index a24b04f2..0f31423d 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -36,6 +36,10 @@ local function save_node_to_store(service, node) }); end +local function delete_node_in_store(service, node_name) + return service.config.nodestore:set(node_name, nil); +end + -- Create and return a new service object local function new(config) config = config or {}; @@ -290,6 +294,15 @@ function service:delete(node, actor) self.data[node]:clear(); end self.data[node] = nil; + + if self.config.nodestore then + local ok, err = delete_node_in_store(self, node); + if not ok then + self.nodes[node] = nil; + return ok, err; + end + end + self.events.fire_event("node-deleted", { node = node, actor = actor }); self.config.broadcaster("delete", node, node_obj.subscribers, nil, actor, node_obj, self); return true; -- cgit v1.2.3