diff --git a/default-direct.lua b/default-direct.lua index 1c16bb5..6d37370 100644 --- a/default-direct.lua +++ b/default-direct.lua @@ -129,7 +129,16 @@ direct.action = function(inlet) event.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 log('Warn', 'ignored an event of type "',event.etype, '"') inlet.discardEvent(event) @@ -177,6 +186,12 @@ end -- direct.init = default.rsync.init +-- +-- Spawns the recursive startup sync +-- (currently) identical to default rsync. +-- +direct.full = default.rsync.full + -- -- Checks the configuration. -- diff --git a/default-rsync.lua b/default-rsync.lua index e422b72..7f566d9 100644 --- a/default-rsync.lua +++ b/default-rsync.lua @@ -313,6 +313,16 @@ rsync.init = function ( event ) + return rsync.full(event) +end + +-- +-- Triggers a full sync event +-- +rsync.full = function + ( + event + ) local config = event.config local inlet = event.inlet diff --git a/default.lua b/default.lua index f1172e2..b8f8664 100644 --- a/default.lua +++ b/default.lua @@ -42,6 +42,7 @@ default.checkgauge = { delay = true, exitcodes = true, init = true, + full = true, maxDelays = true, maxProcesses = true, onAttrib = true, @@ -50,6 +51,7 @@ default.checkgauge = { onDelete = true, onStartup = true, onMove = true, + onFull = true, prepare = true, source = true, target = true, diff --git a/lsyncd.lua b/lsyncd.lua index a698612..58beafb 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -1006,6 +1006,11 @@ local Combiner = ( function return 'stack' end + -- A full sync does not affect us + if d1.etype == 'Full' or d2.etype == 'Full' then + return nil + end + -- two normal events if d1.etype ~= 'Move' and d2.etype ~= 'Move' then @@ -3027,7 +3032,7 @@ local Sync = ( function -- time fo a full sync log('Info', 'Crontab triggered full sync') -- TODO - + self:delay("Full", timestamp, "/", nil) updateNextCronAlarm(self, timestamp) end @@ -4144,6 +4149,7 @@ local Syncs = ( function and not config.onModify and not config.onDelete and not config.onMove + and not config.onFull then local info = debug.getinfo( 3, 'Sl' )