use missing-args for rsyncssh too

This commit is contained in:
Axel Kittenberger 2017-01-05 10:22:00 +01:00
parent 0a0fef20ac
commit d1ef5f3d51
2 changed files with 5 additions and 96 deletions

View File

@ -139,27 +139,6 @@ local replaceRsyncFilter =
end
--
-- Mutates paths for rsync filter rules,
-- changes deletes to multi path patterns
--
-- local pathMutator =
-- function
--(
-- etype,
-- path1,
-- path2
--)
-- if string.byte( path1, -1 ) == 47
-- and etype == 'Delete'
-- then
-- return replaceRsyncFilter( path1 ) .. '***', replaceRsyncFilter( path2 )
-- else
-- return replaceRsyncFilter( path1 ), replaceRsyncFilter( path2 )
-- end
--end
--
-- Spawns rsync for a list of events
--

View File

@ -105,28 +105,6 @@ local replaceRsyncFilter =
end
--
-- Mutates paths for rsync filter rules,
-- changes deletes to multi path patterns
--
local pathMutator =
function
(
etype,
path1,
path2
)
if string.byte( path1, -1 ) == 47
and etype == 'Delete'
then
return replaceRsyncFilter( path1 ) .. '***', replaceRsyncFilter( path2 )
else
return replaceRsyncFilter( path1 ), replaceRsyncFilter( path2 )
end
end
--
-- Spawns rsync for a list of events
--
@ -177,59 +155,12 @@ rsyncssh.action = function
-- gets the list of paths for the event list
-- deletes create multi match patterns
local paths = elist.getPaths( pathMutator )
-- stores all filters by integer index
local filterI = { }
-- stores all filters with path index
local filterP = { }
-- adds one path to the filter
local function addToFilter
(
path
)
if filterP[ path ]
then
return
end
filterP[ path ] = true
table.insert( filterI, path )
end
-- adds a path to the filter.
--
-- rsync needs to have entries for all steps in the path,
-- so the file for example d1/d2/d3/f1 needs following filters:
-- 'd1/', 'd1/d2/', 'd1/d2/d3/' and 'd1/d2/d3/f1'
for _, path in ipairs( paths )
do
if path and path ~= ''
then
addToFilter( path )
local pp = string.match( path, '^(.*/)[^/]+/?' )
while pp
do
addToFilter( pp )
pp = string.match( pp, '^(.*/)[^/]+/?' )
end
end
end
local filterS = table.concat( filterI, '\n' )
local filter0 = table.concat( filterI, '\000' )
local paths = elist.getPaths( )
log(
'Normal',
'Rsyncing list\n',
filterS
table.concat( paths, '\n' )
)
local delete = nil
@ -237,20 +168,19 @@ rsyncssh.action = function
if config.delete == true
or config.delete == 'running'
then
delete = { '--delete', '--ignore-errors' }
delete = { '--delete-missing-args', '--ignore-errors' }
end
spawn(
elist,
config.rsync.binary,
'<', filter0,
'<', table.concat( filterI, '\000' ),
config.rsync._computed,
'-r',
delete,
'--force',
'--from0',
'--include-from=-',
'--exclude=*',
'--files-from=-',
config.source,
config.host .. ':' .. config.targetdir
)