Comparison

util/datamanager.lua @ 3108:df0df92dd58a

util.datamanager: Return an error string when failing to save.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 23 May 2010 23:55:01 +0500
parent 3086:931acb1188b1
child 3722:f15b6ed967b7
comparison
equal deleted inserted replaced
3091:d6a059af2077 3108:df0df92dd58a
143 143
144 -- save the datastore 144 -- save the datastore
145 local f, msg = io_open(getpath(username, host, datastore, nil, true), "w+"); 145 local f, msg = io_open(getpath(username, host, datastore, nil, true), "w+");
146 if not f then 146 if not f then
147 log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil")); 147 log("error", "Unable to write to "..datastore.." storage ('"..msg.."') for user: "..(username or "nil").."@"..(host or "nil"));
148 return; 148 return nil, "Error saving to storage";
149 end 149 end
150 f:write("return "); 150 f:write("return ");
151 append(f, data); 151 append(f, data);
152 f:close(); 152 f:close();
153 if next(data) == nil then -- try to delete empty datastore 153 if next(data) == nil then -- try to delete empty datastore