From 39ac97e87a619d1f52f0806125a6f1df903bd5f1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 22 Mar 2009 20:50:37 +0000 Subject: util.datamanager: Don't delete data when first entry in table is 'false'. My favourite bug so far. --- util/datamanager.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/datamanager.lua b/util/datamanager.lua index 9d3c8592..f67c8864 100644 --- a/util/datamanager.lua +++ b/util/datamanager.lua @@ -102,7 +102,8 @@ function store(username, host, datastore, data) 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 @@ function list_store(username, host, datastore, data) 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 -- cgit v1.2.3