util/datamanager.lua
changeset 7931 9d014aca766f
parent 7930 7132abcf669e
child 7932 4017ea6d2599
equal deleted inserted replaced
7930:7132abcf669e 7931:9d014aca766f
   226 	local filename = getpath(username, host, datastore, ext, true);
   226 	local filename = getpath(username, host, datastore, ext, true);
   227 
   227 
   228 	local ok;
   228 	local ok;
   229 	local f, msg = io_open(filename, "r+");
   229 	local f, msg = io_open(filename, "r+");
   230 	if not f then
   230 	if not f then
       
   231 		return atomic_store(filename, data);
   231 		-- File did probably not exist, let's create it
   232 		-- File did probably not exist, let's create it
   232 		f, msg = io_open(filename, "w");
       
   233 		if not f then
       
   234 			return nil, msg, "open";
       
   235 		end
       
   236 	end
   233 	end
   237 
   234 
   238 	local pos = f:seek("end");
   235 	local pos = f:seek("end");
   239 	ok, msg = fallocate(f, pos, #data);
   236 	ok, msg = fallocate(f, pos, #data);
   240 	if not ok then
   237 	if not ok then