Comparison

util/datamanager.lua @ 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
parent 896:2c0b9e3c11c3
child 932:1ed3e5fe165a
comparison
equal deleted inserted replaced
914:50850f15340c 915:0fe5bf7ab81d
100 return; 100 return;
101 end 101 end
102 f:write("return "); 102 f:write("return ");
103 append(f, data); 103 append(f, data);
104 f:close(); 104 f:close();
105 if not next(data) then -- try to delete empty datastore 105 if next(data) == nil then -- try to delete empty datastore
106 log("debug", "Removing empty %s datastore for user %s@%s", datastore, username, host);
106 os_remove(getpath(username, host, datastore)); 107 os_remove(getpath(username, host, datastore));
107 end 108 end
108 -- we write data even when we are deleting because lua doesn't have a 109 -- we write data even when we are deleting because lua doesn't have a
109 -- platform independent way of checking for non-exisitng files 110 -- platform independent way of checking for non-exisitng files
110 return true; 111 return true;
139 f:write("item("); 140 f:write("item(");
140 append(f, d); 141 append(f, d);
141 f:write(");\n"); 142 f:write(");\n");
142 end 143 end
143 f:close(); 144 f:close();
144 if not next(data) then -- try to delete empty datastore 145 if next(data) == nil then -- try to delete empty datastore
146 log("debug", "Removing empty %s datastore for user %s@%s", datastore, username, host);
145 os_remove(getpath(username, host, datastore, "list")); 147 os_remove(getpath(username, host, datastore, "list"));
146 end 148 end
147 -- we write data even when we are deleting because lua doesn't have a 149 -- we write data even when we are deleting because lua doesn't have a
148 -- platform independent way of checking for non-exisitng files 150 -- platform independent way of checking for non-exisitng files
149 return true; 151 return true;