util.datamanager: Don't delete data when first entry in table is 'false'. My favourit...
authorMatthew Wild <mwild1@gmail.com>
Sun, 22 Mar 2009 20:50:37 +0000 (20:50 +0000)
committerMatthew Wild <mwild1@gmail.com>
Sun, 22 Mar 2009 20:50:37 +0000 (20:50 +0000)
util/datamanager.lua

index 9d3c8592b3293ee8f4fca503190ab467ee0b759e..f67c886478456db206a2b4857870e520a1568fba 100644 (file)
@@ -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