Comparison

util/datamanager.lua @ 4112:09f0ba0cfbfc

util.datamanager: Change from 'Failed to load' to 'Assuming empty' for data store files that do not seem to exist
author Matthew Wild <mwild1@gmail.com>
date Tue, 11 Jan 2011 05:28:07 +0000
parent 4108:e3e3aa286334
child 4452:7de17ca4de14
comparison
equal deleted inserted replaced
4111:4716c7645ad2 4112:09f0ba0cfbfc
113 function load(username, host, datastore) 113 function load(username, host, datastore)
114 local data, ret = loadfile(getpath(username, host, datastore)); 114 local data, ret = loadfile(getpath(username, host, datastore));
115 if not data then 115 if not data then
116 local mode = lfs.attributes(getpath(username, host, datastore), "mode"); 116 local mode = lfs.attributes(getpath(username, host, datastore), "mode");
117 if not mode then 117 if not mode then
118 log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); 118 log("debug", "Assuming empty "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
119 return nil; 119 return nil;
120 else -- file exists, but can't be read 120 else -- file exists, but can't be read
121 -- TODO more detailed error checking and logging? 121 -- TODO more detailed error checking and logging?
122 log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); 122 log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
123 return nil, "Error reading storage"; 123 return nil, "Error reading storage";
205 function list_load(username, host, datastore) 205 function list_load(username, host, datastore)
206 local data, ret = loadfile(getpath(username, host, datastore, "list")); 206 local data, ret = loadfile(getpath(username, host, datastore, "list"));
207 if not data then 207 if not data then
208 local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode"); 208 local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode");
209 if not mode then 209 if not mode then
210 log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); 210 log("debug", "Assuming empty "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
211 return nil; 211 return nil;
212 else -- file exists, but can't be read 212 else -- file exists, but can't be read
213 -- TODO more detailed error checking and logging? 213 -- TODO more detailed error checking and logging?
214 log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); 214 log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
215 return nil, "Error reading storage"; 215 return nil, "Error reading storage";