Changeset

915:0fe5bf7ab81d

util.datamanager: Don't delete data when first entry in table is 'false'. My favourite bug so far.
author Matthew Wild <mwild1@gmail.com>
date Sun, 22 Mar 2009 20:50:37 +0000
parents 914:50850f15340c
children 916:f0743928ef7e
files util/datamanager.lua
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/util/datamanager.lua	Sun Mar 22 17:54:29 2009 +0000
+++ b/util/datamanager.lua	Sun Mar 22 20:50:37 2009 +0000
@@ -102,7 +102,8 @@
 	f:write("return ");
 	append(f, data);
 	f:close();
-	if not next(data) then -- try to delete empty datastore
+	if next(data) == nil then -- try to delete empty datastore
+		log("debug", "Removing empty %s datastore for user %s@%s", datastore, username, host);
 		os_remove(getpath(username, host, datastore));
 	end
 	-- we write data even when we are deleting because lua doesn't have a
@@ -141,7 +142,8 @@
 		f:write(");\n");
 	end
 	f:close();
-	if not next(data) then -- try to delete empty datastore
+	if next(data) == nil then -- try to delete empty datastore
+		log("debug", "Removing empty %s datastore for user %s@%s", datastore, username, host);
 		os_remove(getpath(username, host, datastore, "list"));
 	end
 	-- we write data even when we are deleting because lua doesn't have a