mirror of https://github.com/octoleo/lsyncd.git
trying delete-missing-args
This commit is contained in:
parent
620304c92f
commit
ccae4ac142
|
@ -1,7 +1,7 @@
|
||||||
# preamble
|
# preamble
|
||||||
project( Lsyncd )
|
project( Lsyncd )
|
||||||
cmake_minimum_required( VERSION 2.8 )
|
cmake_minimum_required( VERSION 2.8 )
|
||||||
set( LSYNCD_VERSION 2.2.0 )
|
set( LSYNCD_VERSION 2.2.1-dev )
|
||||||
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" )
|
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,21 +143,21 @@ end
|
||||||
-- Mutates paths for rsync filter rules,
|
-- Mutates paths for rsync filter rules,
|
||||||
-- changes deletes to multi path patterns
|
-- changes deletes to multi path patterns
|
||||||
--
|
--
|
||||||
local pathMutator =
|
-- local pathMutator =
|
||||||
function
|
-- function
|
||||||
(
|
--(
|
||||||
etype,
|
-- etype,
|
||||||
path1,
|
-- path1,
|
||||||
path2
|
-- path2
|
||||||
)
|
--)
|
||||||
if string.byte( path1, -1 ) == 47
|
-- if string.byte( path1, -1 ) == 47
|
||||||
and etype == 'Delete'
|
-- and etype == 'Delete'
|
||||||
then
|
-- then
|
||||||
return replaceRsyncFilter( path1 ) .. '***', replaceRsyncFilter( path2 )
|
-- return replaceRsyncFilter( path1 ) .. '***', replaceRsyncFilter( path2 )
|
||||||
else
|
-- else
|
||||||
return replaceRsyncFilter( path1 ), replaceRsyncFilter( path2 )
|
-- return replaceRsyncFilter( path1 ), replaceRsyncFilter( path2 )
|
||||||
end
|
-- end
|
||||||
end
|
--end
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -177,54 +177,19 @@ rsync.action = function
|
||||||
|
|
||||||
-- gets the list of paths for the event list
|
-- gets the list of paths for the event list
|
||||||
-- deletes create multi match patterns
|
-- deletes create multi match patterns
|
||||||
local paths = elist.getPaths( pathMutator )
|
local paths = elist.getPaths( )
|
||||||
|
|
||||||
-- stores all filters by integer index
|
-- removes trailing slashes from dirs.
|
||||||
local filterI = { }
|
for k, v in ipairs( paths )
|
||||||
|
|
||||||
-- 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
|
do
|
||||||
if path and path ~= ''
|
if string.byte( v, -1 ) == 47
|
||||||
then
|
then
|
||||||
addToFilter( path )
|
paths[ k ] = string.sub( v, 1, -2 )
|
||||||
|
|
||||||
local pp = string.match( path, '^(.*/)[^/]+/?' )
|
|
||||||
|
|
||||||
while pp
|
|
||||||
do
|
|
||||||
addToFilter( pp )
|
|
||||||
|
|
||||||
pp = string.match( pp, '^(.*/)[^/]+/?' )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local filterS = table.concat( filterI, '\n' )
|
local pathsS = table.concat( paths, '\n' )
|
||||||
|
local paths0 = table.concat( paths, '\000' )
|
||||||
local filter0 = table.concat( filterI, '\000' )
|
|
||||||
|
|
||||||
log(
|
log(
|
||||||
'Normal',
|
'Normal',
|
||||||
|
@ -237,7 +202,7 @@ rsync.action = function
|
||||||
if config.delete == true
|
if config.delete == true
|
||||||
or config.delete == 'running'
|
or config.delete == 'running'
|
||||||
then
|
then
|
||||||
delete = { '--delete', '--ignore-errors' }
|
delete = { '--delete-missing-args', '--ignore-errors' }
|
||||||
end
|
end
|
||||||
|
|
||||||
spawn(
|
spawn(
|
||||||
|
@ -249,8 +214,7 @@ rsync.action = function
|
||||||
delete,
|
delete,
|
||||||
'--force',
|
'--force',
|
||||||
'--from0',
|
'--from0',
|
||||||
'--include-from=-',
|
'--files-from=-',
|
||||||
'--exclude=*',
|
|
||||||
config.source,
|
config.source,
|
||||||
config.target
|
config.target
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,7 +32,7 @@ then
|
||||||
lsyncd.terminate( -1 )
|
lsyncd.terminate( -1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
lsyncd_version = '2.2.0'
|
lsyncd_version = '2.2.1-dev'
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue