# HG changeset patch # User Waqas Hussain # Date 1339502127 -18000 # Node ID d8b9fe5900a2332020d4fed0ed4ba6fcac2cf44f # Parent 760a1f367f02dfee3dfb2045ac92abec0d5fe1cd MUC: Handle missing persistent room data. diff -r 760a1f367f02 -r d8b9fe5900a2 plugins/muc/mod_muc.lua --- a/plugins/muc/mod_muc.lua Tue May 29 18:04:29 2012 +0200 +++ b/plugins/muc/mod_muc.lua Tue Jun 12 16:55:27 2012 +0500 @@ -65,19 +65,27 @@ if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end end +local persistent_errors = false; for jid in pairs(persistent_rooms) do local node = jid_split(jid); - local data = datamanager.load(node, muc_host, "config") or {}; - local room = muc_new_room(jid, { - max_history_length = max_history_messages; - }); - room._data = data._data; - room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings - room._affiliations = data._affiliations; - room.route_stanza = room_route_stanza; - room.save = room_save; - rooms[jid] = room; + local data = datamanager.load(node, muc_host, "config"); + if data then + local room = muc_new_room(jid, { + max_history_length = max_history_messages; + }); + room._data = data._data; + room._data.max_history_length = max_history_messages; -- Overwrite old max_history_length in data with current settings + room._affiliations = data._affiliations; + room.route_stanza = room_route_stanza; + room.save = room_save; + rooms[jid] = room; + else -- missing room data + persistent_rooms[jid] = nil; + module:log("error", "Missing data for room '%s', removing from persistent room list", jid); + persistent_errors = true; + end end +if persistent_errors then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end local host_room = muc_new_room(muc_host, { max_history_length = max_history_messages;