diff --git a/default-direct.lua b/default-direct.lua index 74f5f28..a7f6509 100644 --- a/default-direct.lua +++ b/default-direct.lua @@ -83,29 +83,48 @@ direct.action = function(inlet) event.targetPathdir ) elseif event.etype == 'Delete' then - if not config.delete then + + if + config.delete ~= true and + config.delete ~= 'running' + then inlet.discardEvent(event) + return end local tp = event.targetPath + -- extra security check if tp == '' or tp == '/' or not tp then error('Refusing to erase your harddisk!') end + spawn(event, '/bin/rm', '-rf', tp) + elseif event.etype == 'Move' then local tp = event.targetPath + -- extra security check if tp == '' or tp == '/' or not tp then error('Refusing to erase your harddisk!') end + local command = '/bin/mv $1 $2 || /bin/rm -rf $1' - if not config.delete then command = '/bin/mv $1 $2'; end + + if + config.delete ~= true and + config.delete ~= 'running' + then + command = '/bin/mv $1 $2' + end + spawnShell( event, command, event.targetPath, - event2.targetPath) + event2.targetPath + ) + else log('Warn', 'ignored an event of type "',event.etype, '"') inlet.discardEvent(event) @@ -116,6 +135,7 @@ end -- Called when collecting a finished child process -- direct.collect = function(agent, exitcode) + local config = agent.config if not agent.isList and agent.etype == 'Init' then diff --git a/default-rsync.lua b/default-rsync.lua index 4ceb233..c4ea741 100644 --- a/default-rsync.lua +++ b/default-rsync.lua @@ -192,7 +192,7 @@ rsync.action = function( inlet ) local config = inlet.getConfig( ) local delete = nil - if config.delete then + if config.delete == true or config.delete == 'running' then delete = { '--delete', '--ignore-errors' } end @@ -233,7 +233,7 @@ rsync.init = function(event) target = config.host .. ':' .. config.targetdir end - if config.delete then + if config.delete == true or config.delete == 'startup' then delete = { '--delete', '--ignore-errors' } end diff --git a/default-rsyncssh.lua b/default-rsyncssh.lua index e5cabd8..1cd36b4 100644 --- a/default-rsyncssh.lua +++ b/default-rsyncssh.lua @@ -93,7 +93,11 @@ rsyncssh.action = function( inlet ) -- instead of constructing rsync filters if event.etype == 'Delete' then - if not config.delete then + + if + config.delete ~= true and + config.delete ~= 'running' + then inlet.discardEvent(event) return end