Comparison

util/datamanager.lua @ 13234:c886ea087b38

util.datamanager: Disable blockwise removal In desperate need of tests
author Kim Alvefur <zash@zash.se>
date Fri, 21 Jul 2023 18:28:16 +0200
parent 13231:6a11d92ae436
child 13235:dbd7a6b09ada
comparison
equal deleted inserted replaced
13233:37d67b5f9768 13234:c886ea087b38
30 -- Extract directory separator from package.config (an undocumented string that comes with lua) 30 -- Extract directory separator from package.config (an undocumented string that comes with lua)
31 local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" ) 31 local path_separator = assert ( package.config:match ( "^([^\n]+)" ) , "package.config not in standard form" )
32 32
33 local prosody = prosody; 33 local prosody = prosody;
34 34
35 --luacheck: ignore 211/blocksize 211/remove_blocks
35 local blocksize = 0x1000; 36 local blocksize = 0x1000;
36 local raw_mkdir = lfs.mkdir; 37 local raw_mkdir = lfs.mkdir;
37 local atomic_append; 38 local atomic_append;
38 local remove_blocks; 39 local remove_blocks;
39 local ENOENT = 2; 40 local ENOENT = 2;
40 pcall(function() 41 pcall(function()
41 local pposix = require "prosody.util.pposix"; 42 local pposix = require "prosody.util.pposix";
42 raw_mkdir = pposix.mkdir or raw_mkdir; -- Doesn't trample on umask 43 raw_mkdir = pposix.mkdir or raw_mkdir; -- Doesn't trample on umask
43 atomic_append = pposix.atomic_append; 44 atomic_append = pposix.atomic_append;
44 remove_blocks = pposix.remove_blocks; 45 -- remove_blocks = pposix.remove_blocks;
45 ENOENT = pposix.ENOENT or ENOENT; 46 ENOENT = pposix.ENOENT or ENOENT;
46 end); 47 end);
47 48
48 local _ENV = nil; 49 local _ENV = nil;
49 -- luacheck: std none 50 -- luacheck: std none
581 local offset = new_first.start; 582 local offset = new_first.start;
582 if offset == 0 then 583 if offset == 0 then
583 return true; 584 return true;
584 end 585 end
585 586
587 --[[
586 if remove_blocks then 588 if remove_blocks then
587 local f, err = io_open(list_filename, "r+"); 589 local f, err = io_open(list_filename, "r+");
588 if not f then 590 if not f then
589 return f, err; 591 return f, err;
590 end 592 end
618 shift_index(index_filename, index, trim_to, offset); -- Shift or delete the index 620 shift_index(index_filename, index, trim_to, offset); -- Shift or delete the index
619 return ok, err; 621 return ok, err;
620 end 622 end
621 end 623 end
622 end 624 end
625 --]]
623 626
624 local r, err = io_open(list_filename, "r"); 627 local r, err = io_open(list_filename, "r");
625 if not r then 628 if not r then
626 return nil, err; 629 return nil, err;
627 end 630 end