Software /
code /
prosody
Comparison
util/pubsub.lua @ 8951:9baac001fccb
util.pubsub: Persist nodes on configuration change
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 01 Jul 2018 04:27:09 +0200 |
parent | 8950:03ba5b4f131a |
child | 8952:15bb54f96dd1 |
comparison
equal
deleted
inserted
replaced
8950:03ba5b4f131a | 8951:9baac001fccb |
---|---|
485 local node_obj = self.nodes[node]; | 485 local node_obj = self.nodes[node]; |
486 if not node_obj then | 486 if not node_obj then |
487 return false, "item-not-found"; | 487 return false, "item-not-found"; |
488 end | 488 end |
489 | 489 |
490 if new_config["persist_items"] ~= node_obj.config["persist_items"] then | 490 local old_config = node_obj.config; |
491 node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); | |
492 | |
493 if self.config.nodestore then | |
494 local ok, err = save_node_to_store(self, node_obj); | |
495 if not ok then | |
496 node_obj.config = old_config; | |
497 return ok, "internal-server-error"; | |
498 end | |
499 end | |
500 | |
501 if old_config["persist_items"] ~= node_obj.config["persist_items"] then | |
491 self.data[node] = self.config.itemstore(self.nodes[node].config, node); | 502 self.data[node] = self.config.itemstore(self.nodes[node].config, node); |
492 elseif new_config["max_items"] ~= node_obj.config["max_items"] then | 503 elseif old_config["max_items"] ~= node_obj.config["max_items"] then |
493 self.data[node]:resize(new_config["max_items"]); | 504 self.data[node]:resize(self.nodes[node].config["max_items"]); |
494 end | 505 end |
495 | |
496 node_obj.config = setmetatable(new_config, {__index=self.node_defaults}); | |
497 | 506 |
498 return true; | 507 return true; |
499 end | 508 end |
500 | 509 |
501 return { | 510 return { |