Comparison

util/datamanager.lua @ 6995:807b0b2ee545

util.datamanager: Skip past second check if first attemtp to open file succeeds
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 20:18:24 +0100
parent 6994:507301531cf5
child 6996:644b1bddc676
comparison
equal deleted inserted replaced
6994:507301531cf5 6995:807b0b2ee545
212 local function append(username, host, datastore, ext, data) 212 local function append(username, host, datastore, ext, data)
213 local filename = getpath(username, host, datastore, ext, true); 213 local filename = getpath(username, host, datastore, ext, true);
214 local f, msg = io_open(filename, "r+"); 214 local f, msg = io_open(filename, "r+");
215 if not f then 215 if not f then
216 f, msg = io_open(filename, "w"); 216 f, msg = io_open(filename, "w");
217 end 217 if not f then
218 if not f then 218 return nil, msg;
219 return nil, msg; 219 end
220 end 220 end
221 local pos = f:seek("end"); 221 local pos = f:seek("end");
222 local ok, msg = fallocate(f, pos, #data); 222 local ok, msg = fallocate(f, pos, #data);
223 f:seek("set", pos); 223 f:seek("set", pos);
224 if ok then 224 if ok then