Comparison

util/datamanager.lua @ 13231:6a11d92ae436

util.datamanager: Disable block alignment Until we have more test coverage. Somehow the index becomes incorrect after inserting padding, unclear why.
author Kim Alvefur <zash@zash.se>
date Fri, 21 Jul 2023 18:03:22 +0200
parent 13186:affaf6d08d26
child 13234:c886ea087b38
comparison
equal deleted inserted replaced
13230:26c30844cac6 13231:6a11d92ae436
243 return atomic_store(filename, data); 243 return atomic_store(filename, data);
244 -- File did probably not exist, let's create it 244 -- File did probably not exist, let's create it
245 end 245 end
246 246
247 local pos = f:seek("end"); 247 local pos = f:seek("end");
248 --[[ TODO needs tests
248 if (blocksize-(pos%blocksize)) < (#data%blocksize) then 249 if (blocksize-(pos%blocksize)) < (#data%blocksize) then
249 -- pad to blocksize with newlines so that the next item is both on a new 250 -- pad to blocksize with newlines so that the next item is both on a new
250 -- block and a new line 251 -- block and a new line
251 atomic_append(f, ("\n"):rep(blocksize-(pos%blocksize))); 252 atomic_append(f, ("\n"):rep(blocksize-(pos%blocksize)));
252 pos = f:seek("end"); 253 pos = f:seek("end");
253 end 254 end
255 --]]
254 256
255 local ok, msg = atomic_append(f, data); 257 local ok, msg = atomic_append(f, data);
256 258
257 if not ok then 259 if not ok then
258 f:close(); 260 f:close();