Diff

util/datamanager.lua @ 3722:f15b6ed967b7

util.datamanager: When failing to load a list file, and the file exists, log an error, and return nil, error.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 10 Dec 2010 00:21:09 +0500
parent 3108:df0df92dd58a
child 3723:72a917d910a4
line wrap: on
line diff
--- a/util/datamanager.lua	Fri Dec 10 00:07:28 2010 +0500
+++ b/util/datamanager.lua	Fri Dec 10 00:21:09 2010 +0500
@@ -204,8 +204,15 @@
 function list_load(username, host, datastore)
 	local data, ret = loadfile(getpath(username, host, datastore, "list"));
 	if not data then
-		log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
-		return nil;
+		local mode = lfs.attributes(getpath(username, host, datastore, "list"), "mode");
+		if not mode then
+			log("debug", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+			return nil;
+		else -- file exists, but can't be read
+			-- TODO more detailed error checking and logging?
+			log("error", "Failed to load "..datastore.." storage ('"..ret.."') for user: "..(username or "nil").."@"..(host or "nil"));
+			return nil, "Error reading storage";
+		end
 	end
 	local items = {};
 	setfenv(data, {item = function(i) t_insert(items, i); end});