From 054a2d38c1ab12bf6bda2c22b775a91b9fb4dd4a Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Mon, 24 May 2010 00:29:45 +0500 Subject: rostermanager: Mark rosters which fail to load as broken, and never save them. --- core/rostermanager.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core/rostermanager.lua') diff --git a/core/rostermanager.lua b/core/rostermanager.lua index a3315245..285cf4f6 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -96,7 +96,7 @@ function load_roster(username, host) local data, err = datamanager.load(username, host, "roster"); roster = data or {}; if user then user.roster = roster; end - if not roster[false] then roster[false] = { }; end + if not roster[false] then roster[false] = { broken = err or nil }; end if roster[jid] then roster[jid] = nil; log("warn", "roster for "..jid.." has a self-contact"); @@ -125,6 +125,7 @@ function save_roster(username, host, roster) if metadata.version ~= true then metadata.version = (metadata.version or 0) + 1; end + if roster[false].broken then return nil, "Not saving broken roster" end return datamanager.store(username, host, "roster", roster); end log("warn", "save_roster: user had no roster to save"); -- cgit v1.2.3 From e1b4298fde007769a41c0a97fbfcc2f44bb383f9 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Mon, 24 May 2010 00:35:08 +0500 Subject: rostermanager: Return an error string when subscription test fails due to an error. --- core/rostermanager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/rostermanager.lua') diff --git a/core/rostermanager.lua b/core/rostermanager.lua index 285cf4f6..506cf205 100644 --- a/core/rostermanager.lua +++ b/core/rostermanager.lua @@ -191,9 +191,9 @@ function process_inbound_unsubscribe(username, host, jid) end function is_contact_subscribed(username, host, jid) - local roster = load_roster(username, host); + local roster, err = load_roster(username, host); local item = roster[jid]; - return item and (item.subscription == "from" or item.subscription == "both"); + return item and (item.subscription == "from" or item.subscription == "both"), err; end function is_contact_pending_in(username, host, jid) -- cgit v1.2.3