202 end |
202 end |
203 |
203 |
204 function list_load(username, host, datastore) |
204 function list_load(username, host, datastore) |
205 local data, ret = loadfile(getpath(username, host, datastore, "list")); |
205 local data, ret = loadfile(getpath(username, host, datastore, "list")); |
206 if not data then |
206 if not data then |
207 log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); |
207 local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode"); |
208 return nil; |
208 if not mode then |
|
209 log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); |
|
210 return nil; |
|
211 else -- file exists, but can't be read |
|
212 -- TODO more detailed error checking and logging? |
|
213 log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil")); |
|
214 return nil, "Error reading storage"; |
|
215 end |
209 end |
216 end |
210 local items = {}; |
217 local items = {}; |
211 setfenv(data, {item = function(i) t_insert(items, i); end}); |
218 setfenv(data, {item = function(i) t_insert(items, i); end}); |
212 local success, ret = pcall(data); |
219 local success, ret = pcall(data); |
213 if not success then |
220 if not success then |