possible unzstd implemented, but deactivated.

This commit is contained in:
Denis Knauf 2024-04-09 21:43:50 +02:00
parent 5fee6133a5
commit 0492207d37

View file

@ -34,7 +34,7 @@ require 'pathname'
require 'set' require 'set'
def maildirlock path def maildirlock path
return yield # currently deactivated, maildirlock does not work return yield # currently deactivated
io = IO.popen ['/usr/lib/dovecot/maildirlock', path.to_s, '10'], out: %i[child out] io = IO.popen ['/usr/lib/dovecot/maildirlock', path.to_s, '10'], out: %i[child out]
lockpidfile = Pathname.new io.read lockpidfile = Pathname.new io.read
pid, pst = Process.wait2 pid, pst = Process.wait2
@ -99,7 +99,18 @@ def unxz mf, tf
if 0 == pst.exitstatus if 0 == pst.exitstatus
true true
else else
log " Compression failed for: #{mf}" log " Decompression [xz] failed for: #{mf}"
false
end
end
def unzstd mf, tf
pid = Process.spawn 'zstd', '-d', umask: 0177, in: mf.to_s, out: tf.to_s, close_others: true
_pid, pst = Process.waitpid2( pid)
if 0 == pst.exitstatus
true
else
log " Decompression [zstd] failed for: #{mf}"
false false
end end
end end
@ -230,6 +241,20 @@ def process xf
end end
end end
if false and :zst == fs
nf = mf.new compressed: false
tf = nf.new dir: :tmp
return log " Uncompressed mail already exist: #{nf}" if nf.exist?
return log " Temporary file already exist: #{tf}" if tf.exist?
STDERR.print "<\r"
return unless unzstd mf.to_s, tf.to_s
STDERR.print "<<\r"
restat tf, stat
place mf, nf, tf
STDERR.print "<<<\r"
return process(nf)
end
if :xz == fs if :xz == fs
nf = mf.new compressed: false nf = mf.new compressed: false
tf = nf.new dir: :tmp tf = nf.new dir: :tmp