cleanups, removing Lsyncd 2.0.x backward compatibility syntax it was blocked by checkgauge already anyway

This commit is contained in:
Axel Kittenberger 2016-12-13 17:40:30 +01:00
parent 8927426be2
commit 155dbf155c
1 changed files with 56 additions and 78 deletions

View File

@ -111,13 +111,18 @@ rsync.checkgauge = {
-- Exclusions are already handled by not having -- Exclusions are already handled by not having
-- events for them. -- events for them.
-- --
rsync.action = function( inlet ) rsync.action = function
(
inlet
)
-- --
-- gets all events ready for syncing -- gets all events ready for syncing
-- --
local elist = inlet.getEvents( local elist = inlet.getEvents(
function(event) function
(
event
)
return event.etype ~= 'Init' and event.etype ~= 'Blanket' return event.etype ~= 'Init' and event.etype ~= 'Blanket'
end end
) )
@ -125,8 +130,12 @@ rsync.action = function( inlet )
-- --
-- Replaces what rsync would consider filter rules by literals -- Replaces what rsync would consider filter rules by literals
-- --
local function sub( p ) local function sub
if not p then (
p
)
if not p
then
return return
end end
@ -142,8 +151,15 @@ rsync.action = function( inlet )
-- Deletes create multi match patterns -- Deletes create multi match patterns
-- --
local paths = elist.getPaths( local paths = elist.getPaths(
function( etype, path1, path2 ) function
if string.byte( path1, -1 ) == 47 and etype == 'Delete' then (
etype,
path1,
path2
)
if string.byte( path1, -1 ) == 47
and etype == 'Delete'
then
return sub( path1 )..'***', sub( path2 ) return sub( path1 )..'***', sub( path2 )
else else
return sub( path1 ), sub( path2 ) return sub( path1 ), sub( path2 )
@ -164,9 +180,12 @@ rsync.action = function( inlet )
-- --
-- Adds one path to the filter -- Adds one path to the filter
-- --
local function addToFilter( path ) local function addToFilter
(
if filterP[ path ] then path
)
if filterP[ path ]
then
return return
end end
@ -182,21 +201,20 @@ rsync.action = function( inlet )
-- so the file for example d1/d2/d3/f1 needs following filters: -- so the file for example d1/d2/d3/f1 needs following filters:
-- 'd1/', 'd1/d2/', 'd1/d2/d3/' and 'd1/d2/d3/f1' -- 'd1/', 'd1/d2/', 'd1/d2/d3/' and 'd1/d2/d3/f1'
-- --
for _, path in ipairs( paths ) do for _, path in ipairs( paths )
do
if path and path ~= '' then if path and path ~= ''
then
addToFilter(path) addToFilter(path)
local pp = string.match( path, '^(.*/)[^/]+/?' ) local pp = string.match( path, '^(.*/)[^/]+/?' )
while pp do while pp
do
addToFilter(pp) addToFilter(pp)
pp = string.match( pp, '^(.*/)[^/]+/?' ) pp = string.match( pp, '^(.*/)[^/]+/?' )
end end
end end
end end
local filterS = table.concat( filterI, '\n' ) local filterS = table.concat( filterI, '\n' )
@ -209,9 +227,12 @@ rsync.action = function( inlet )
) )
local config = inlet.getConfig( ) local config = inlet.getConfig( )
local delete = nil local delete = nil
if config.delete == true or config.delete == 'running' then if config.delete == true
or config.delete == 'running'
then
delete = { '--delete', '--ignore-errors' } delete = { '--delete', '--ignore-errors' }
end end
@ -234,14 +255,20 @@ end
-- --
-- Spawns the recursive startup sync -- Spawns the recursive startup sync.
-- --
rsync.init = function(event) rsync.init = function
(
event
)
local config = event.config local config = event.config
local inlet = event.inlet local inlet = event.inlet
local excludes = inlet.getExcludes( ) local excludes = inlet.getExcludes( )
local delete = nil local delete = nil
local target = config.target local target = config.target
if not target if not target
@ -254,7 +281,8 @@ rsync.init = function(event)
target = config.host .. ':' .. config.targetdir target = config.host .. ':' .. config.targetdir
end end
if config.delete == true or config.delete == 'startup' if config.delete == true
or config.delete == 'startup'
then then
delete = { '--delete', '--ignore-errors' } delete = { '--delete', '--ignore-errors' }
end end
@ -313,12 +341,12 @@ end
-- --
-- Prepares and checks a syncs configuration on startup. -- Prepares and checks a syncs configuration on startup.
-- --
rsync.prepare = rsync.prepare = function
function( (
config, -- the configuration config, -- the configuration
level, -- additional error level for inherited use ( by rsyncssh ) level, -- additional error level for inherited use ( by rsyncssh )
skipTarget -- used by rsyncssh, do not check for target skipTarget -- used by rsyncssh, do not check for target
) )
-- First let default.prepare test the checkgauge -- First let default.prepare test the checkgauge
default.prepare( config, level + 6 ) default.prepare( config, level + 6 )
@ -331,56 +359,6 @@ rsync.prepare =
) )
end end
if config.rsyncOps
then
error(
'"rsyncOps" is outdated please use the new rsync = { ... } syntax.',
level
)
end
if config.rsyncOpts and config.rsync._extra
then
error(
'"rsyncOpts" is outdated in favor of the new rsync = { ... } syntax\n"' +
'for which you provided the _extra attribute as well.\n"' +
'Please remove rsyncOpts from your config.',
level
)
end
if config.rsyncOpts
then
log(
'Warn',
'"rsyncOpts" is outdated. Please use the new rsync = { ... } syntax."'
)
config.rsync._extra = config.rsyncOpts
config.rsyncOpts = nil
end
if config.rsyncBinary and config.rsync.binary
then
error(
'"rsyncBinary is outdated in favor of the new rsync = { ... } syntax\n"'+
'for which you provided the binary attribute as well.\n"' +
"Please remove rsyncBinary from your config.'",
level
)
end
if config.rsyncBinary
then
log(
'Warn',
'"rsyncBinary" is outdated. Please use the new rsync = { ... } syntax."'
)
config.rsync.binary = config.rsyncBinary
config.rsyncOpts = nil
end
-- checks if the _computed argument exists already -- checks if the _computed argument exists already
if config.rsync._computed if config.rsync._computed
then then