Finish full sync cron trigger

This commit is contained in:
Daniel Poelzleithner 2022-03-31 03:54:21 +02:00
parent 9ec4f42888
commit ff84a35d4d
4 changed files with 34 additions and 1 deletions

View File

@ -129,7 +129,16 @@ direct.action = function(inlet)
event.targetPath, event.targetPath,
event2.targetPath event2.targetPath
) )
elseif event.etype == 'Full' then
local tp = event.targetPath
-- extra security check
if tp == '' or tp == '/' or not tp then
error('Refusing to erase your harddisk!')
end
-- trigger full sync function
direct.full(event)
else else
log('Warn', 'ignored an event of type "',event.etype, '"') log('Warn', 'ignored an event of type "',event.etype, '"')
inlet.discardEvent(event) inlet.discardEvent(event)
@ -177,6 +186,12 @@ end
-- --
direct.init = default.rsync.init direct.init = default.rsync.init
--
-- Spawns the recursive startup sync
-- (currently) identical to default rsync.
--
direct.full = default.rsync.full
-- --
-- Checks the configuration. -- Checks the configuration.
-- --

View File

@ -313,6 +313,16 @@ rsync.init = function
( (
event event
) )
return rsync.full(event)
end
--
-- Triggers a full sync event
--
rsync.full = function
(
event
)
local config = event.config local config = event.config
local inlet = event.inlet local inlet = event.inlet

View File

@ -42,6 +42,7 @@ default.checkgauge = {
delay = true, delay = true,
exitcodes = true, exitcodes = true,
init = true, init = true,
full = true,
maxDelays = true, maxDelays = true,
maxProcesses = true, maxProcesses = true,
onAttrib = true, onAttrib = true,
@ -50,6 +51,7 @@ default.checkgauge = {
onDelete = true, onDelete = true,
onStartup = true, onStartup = true,
onMove = true, onMove = true,
onFull = true,
prepare = true, prepare = true,
source = true, source = true,
target = true, target = true,

View File

@ -1006,6 +1006,11 @@ local Combiner = ( function
return 'stack' return 'stack'
end end
-- A full sync does not affect us
if d1.etype == 'Full' or d2.etype == 'Full' then
return nil
end
-- two normal events -- two normal events
if d1.etype ~= 'Move' and d2.etype ~= 'Move' if d1.etype ~= 'Move' and d2.etype ~= 'Move'
then then
@ -3027,7 +3032,7 @@ local Sync = ( function
-- time fo a full sync -- time fo a full sync
log('Info', 'Crontab triggered full sync') log('Info', 'Crontab triggered full sync')
-- TODO -- TODO
self:delay("Full", timestamp, "/", nil)
updateNextCronAlarm(self, timestamp) updateNextCronAlarm(self, timestamp)
end end
@ -4144,6 +4149,7 @@ local Syncs = ( function
and not config.onModify and not config.onModify
and not config.onDelete and not config.onDelete
and not config.onMove and not config.onMove
and not config.onFull
then then
local info = debug.getinfo( 3, 'Sl' ) local info = debug.getinfo( 3, 'Sl' )