Comparison

core/rostermanager.lua @ 3110:7426727548ed

rostermanager: Mark rosters which fail to load as broken, and never save them.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 24 May 2010 00:29:45 +0500
parent 3090:f14d2962f32c
child 3111:826cb5f1859b
comparison
equal deleted inserted replaced
3109:34280b1544fc 3110:7426727548ed
94 log("debug", "load_roster: loading for offline user: "..username.."@"..host); 94 log("debug", "load_roster: loading for offline user: "..username.."@"..host);
95 end 95 end
96 local data, err = datamanager.load(username, host, "roster"); 96 local data, err = datamanager.load(username, host, "roster");
97 roster = data or {}; 97 roster = data or {};
98 if user then user.roster = roster; end 98 if user then user.roster = roster; end
99 if not roster[false] then roster[false] = { }; end 99 if not roster[false] then roster[false] = { broken = err or nil }; end
100 if roster[jid] then 100 if roster[jid] then
101 roster[jid] = nil; 101 roster[jid] = nil;
102 log("warn", "roster for "..jid.." has a self-contact"); 102 log("warn", "roster for "..jid.." has a self-contact");
103 end 103 end
104 if not err then 104 if not err then
123 roster[false] = metadata; 123 roster[false] = metadata;
124 end 124 end
125 if metadata.version ~= true then 125 if metadata.version ~= true then
126 metadata.version = (metadata.version or 0) + 1; 126 metadata.version = (metadata.version or 0) + 1;
127 end 127 end
128 if roster[false].broken then return nil, "Not saving broken roster" end
128 return datamanager.store(username, host, "roster", roster); 129 return datamanager.store(username, host, "roster", roster);
129 end 130 end
130 log("warn", "save_roster: user had no roster to save"); 131 log("warn", "save_roster: user had no roster to save");
131 return nil; 132 return nil;
132 end 133 end