Skip to content

Commit

Permalink
allow true, false, 'running' and 'startup' for the delete parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
axkibe committed Oct 9, 2012
1 parent a82f4da commit 5f01a04
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
26 changes: 23 additions & 3 deletions default-direct.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions default-rsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion default-rsyncssh.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5f01a04

Please sign in to comment.