aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-11-09 17:19:11 +0100
committerKim Alvefur <zash@zash.se>2017-11-09 17:19:11 +0100
commit5bafb3680d035145880aacf9845db7bf69dd2b35 (patch)
tree13b19772054df606dd0a0cf77ba363635270714f
parent57b865f8b9a83f984d41d3374687a86b7245e22d (diff)
downloadprosody-5bafb3680d035145880aacf9845db7bf69dd2b35.tar.gz
prosody-5bafb3680d035145880aacf9845db7bf69dd2b35.zip
util.pubsub: Recreate itemstore if persist_items changes or resize it if max_items changes
-rw-r--r--util/pubsub.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 8122e2f2..607ec49d 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -431,14 +431,14 @@ function service:set_node_config(node, actor, new_config)
return false, "item-not-found";
end
- for k,v in pairs(new_config) do
- node_obj.config[k] = v;
- end
- local new_data = self.config.itemstore(self.nodes[node].config, node);
- for key, value in self.data[node]:items() do
- new_data:set(key, value);
+ if new_config["persist_items"] ~= node_obj.config["persist_items"] then
+ self.data[node] = self.config.itemstore(self.nodes[node].config, node);
+ elseif new_config["max_items"] ~= node_obj.config["max_items"] then
+ self.data[node]:resize(new_config["max_items"]);
end
- self.data[node] = new_data;
+
+ node_obj.config = setmetatable(new_config, {__index=self.node_defaults});
+
return true;
end