Changeset

3476:4ce945490a24

mod_bookmarks: Actually save node config
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 06 Mar 2019 17:46:57 +0100
parents 3475:820c891a54cc
children 3477:1f2381492c9f
files mod_bookmarks/mod_bookmarks.lua
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_bookmarks/mod_bookmarks.lua	Wed Mar 06 01:30:54 2019 +0100
+++ b/mod_bookmarks/mod_bookmarks.lua	Wed Mar 06 17:46:57 2019 +0100
@@ -125,9 +125,25 @@
 	if node ~= "storage:bookmarks" then
 		return;
 	end
-	local node_config = service.nodes[node].config;
+	local ok, config = service:get_node_config(node, actor);
+	if not ok then
+		module:log("error", "Failed to get node config of %s: %s", node, config);
+		return;
+	end
+	local changed = false;
 	for config_field, value in pairs(default_options) do
-		node_config[config_field] = value;
+		if node_config[config_field] ~= value then
+			node_config[config_field] = value;
+			changed = true;
+		end
+	end
+	if not changed then
+		return;
+	end
+	local ok, err = service:set_node_config(node, actor, config);
+	if not ok then
+		module:log("error", "Failed to set node config of %s: %s", node, err);
+		return;
 	end
 end