Comparison

util/datamanager.lua @ 6997:0ab228bc21c6

util.datamanager: Handle potential issues from fallocate
author Kim Alvefur <zash@zash.se>
date Fri, 11 Dec 2015 20:24:36 +0100
parent 6996:644b1bddc676
child 6998:86607fe755b6
comparison
equal deleted inserted replaced
6996:644b1bddc676 6997:0ab228bc21c6
220 return nil, msg; 220 return nil, msg;
221 end 221 end
222 end 222 end
223 local pos = f:seek("end"); 223 local pos = f:seek("end");
224 ok, msg = fallocate(f, pos, #data); 224 ok, msg = fallocate(f, pos, #data);
225 f:seek("set", pos); 225 if not ok then
226 log("warn", "fallocate() failed: %s", tostring(msg));
227 -- This doesn't work on every file system
228 end
229
230 if f:seek() ~= pos then
231 log("debug", "fallocate() changed file position");
232 f:seek("set", pos);
233 end
234
226 if ok then 235 if ok then
227 f:write(data); 236 f:write(data);
228 else 237 else
229 return ok, msg; 238 return ok, msg;
230 end 239 end