This commit is contained in:
Axel Kittenberger 2018-03-01 11:26:12 +01:00
parent 1e0d867f80
commit 465e173983
3 changed files with 29 additions and 70 deletions

View File

@ -16,16 +16,9 @@
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if not default if not default then error( 'default not loaded' ) end
then
error( 'default not loaded' )
end
if default.rsync then error( 'default-rsync already loaded' ) end
if default.rsync
then
error( 'default-rsync already loaded' )
end
local rsync = { } local rsync = { }
@ -186,7 +179,6 @@ rsync.action = function
( (
path path
) )
if filterP[ path ] then return end if filterP[ path ] then return end
filterP[ path ] = true filterP[ path ] = true

View File

@ -388,13 +388,10 @@ local function check
) )
for k, v in pairs( config ) for k, v in pairs( config )
do do
if not gauge[k] if not gauge[ k ]
then then
error( error(
'Parameter "' 'Parameter "' .. subtable .. k .. '" unknown.'
.. subtable
.. k
.. '" unknown.'
.. ' ( if this is not a typo add it to checkgauge )', .. ' ( if this is not a typo add it to checkgauge )',
level level
); );
@ -405,10 +402,7 @@ local function check
if type( v ) ~= 'table' if type( v ) ~= 'table'
then then
error( error(
'Parameter "' 'Parameter "' .. subtable .. k .. '" must be a table.',
.. subtable
.. k
.. '" must be a table.',
level level
) )
end end
@ -432,10 +426,7 @@ default.prepare = function
local gauge = config.checkgauge local gauge = config.checkgauge
if not gauge if not gauge then return end
then
return
end
check( config, gauge, '', level + 1 ) check( config, gauge, '', level + 1 )
end end

View File

@ -58,11 +58,9 @@ readdir = lsyncd.readdir
-- Coping globals to ensure userscripts cannot change this. -- Coping globals to ensure userscripts cannot change this.
-- --
local log = log local log = log
local terminate = terminate local terminate = terminate
local now = now local now = now
local readdir = readdir
-- --
-- Predeclarations. -- Predeclarations.
@ -123,8 +121,8 @@ local settingsSafe
-- --
-- Array tables error if accessed with a non-number. -- Array tables error if accessed with a non-number.
-- --
local Array = ( function( ) local Array = ( function
( )
-- --
-- Metatable. -- Metatable.
-- --
@ -1881,8 +1879,8 @@ end )( )
-- --
-- A set of exclude patterns. -- A set of exclude patterns.
-- --
local Excludes = ( function( ) local Excludes = ( function
( )
-- --
-- Turns a rsync like file pattern to a lua pattern. -- Turns a rsync like file pattern to a lua pattern.
-- ( at best it can ) -- ( at best it can )
@ -2068,7 +2066,6 @@ local Excludes = ( function( )
-- Public interface. -- Public interface.
-- --
return { new = new } return { new = new }
end )( ) end )( )
@ -2077,8 +2074,8 @@ end )( )
-- --
-- Filters allow excludes and includes -- Filters allow excludes and includes
-- --
local Filters = ( function( ) local Filters = ( function
( )
-- --
-- Turns a rsync like file pattern to a lua pattern. -- Turns a rsync like file pattern to a lua pattern.
-- ( at best it can ) -- ( at best it can )
@ -2395,18 +2392,12 @@ local Sync = ( function
local alarm = self.config.delay local alarm = self.config.delay
-- delays at least 1 second -- delays at least 1 second
if alarm < 1 if alarm < 1 then alarm = 1 end
then
alarm = 1
end
delay:wait( now( ) + alarm ) delay:wait( now( ) + alarm )
end end
else else
log( log( 'Delay', 'collected a list' )
'Delay',
'collected a list'
)
local rc = self.config.collect( local rc = self.config.collect(
InletFactory.dl2el( delay ), InletFactory.dl2el( delay ),
@ -2503,11 +2494,7 @@ local Sync = ( function
if isdir then pd = pd..'/' end if isdir then pd = pd..'/' end
log( log( 'Delay', 'Create creates Create on ', pd )
'Delay',
'Create creates Create on ',
pd
)
delay( self, 'Create', time, pd, nil ) delay( self, 'Create', time, pd, nil )
end end
@ -2876,7 +2863,6 @@ local Sync = ( function
return d return d
end end
end end
end end
-- --
@ -2975,7 +2961,6 @@ local Sync = ( function
filters = nil, filters = nil,
-- functions -- functions
addBlanketDelay = addBlanketDelay, addBlanketDelay = addBlanketDelay,
addExclude = addExclude, addExclude = addExclude,
addInitDelay = addInitDelay, addInitDelay = addInitDelay,
@ -3065,7 +3050,6 @@ local Sync = ( function
-- Public interface -- Public interface
-- --
return { new = new } return { new = new }
end )( ) end )( )
@ -3148,14 +3132,14 @@ local Syncs = ( function
do do
if if
( (
type( k ) ~= 'number' or type( k ) ~= 'number'
verbatim or or verbatim
cs._verbatim == true or cs._verbatim == true
) )
and and
( (
type( cs._merge ) ~= 'table' or type( cs._merge ) ~= 'table'
cs._merge[ k ] == true or cs._merge[ k ] == true
) )
then then
inheritKV( cd, k, v ) inheritKV( cd, k, v )
@ -3166,11 +3150,8 @@ local Syncs = ( function
-- ( for non-verbatim tables ) -- ( for non-verbatim tables )
if cs._verbatim ~= true if cs._verbatim ~= true
then then
local n = nil
for k, v in ipairs( cs ) for k, v in ipairs( cs )
do do
n = k
if type( v ) == 'table' if type( v ) == 'table'
then then
inherit( cd, v ) inherit( cd, v )
@ -3193,10 +3174,7 @@ local Syncs = ( function
) )
-- don't merge inheritance controls -- don't merge inheritance controls
if k == '_merge' or k == '_verbatim' if k == '_merge' or k == '_verbatim' then return end
then
return
end
local dtype = type( cd [ k ] ) local dtype = type( cd [ k ] )
@ -3212,7 +3190,6 @@ local Syncs = ( function
then then
inherit( cd[ k ], v, k == 'exitcodes' ) inherit( cd[ k ], v, k == 'exitcodes' )
end end
elseif dtype == 'nil' elseif dtype == 'nil'
then then
cd[ k ] = v cd[ k ] = v
@ -5259,17 +5236,16 @@ end
-- --
-- Returns an Inlet to that sync. -- Returns an Inlet to that sync.
-- --
function sync( opts ) function sync
(
if lsyncdStatus ~= 'init' then opts
error( )
'Sync can only be created during initialization.', if lsyncdStatus ~= 'init'
2 then
) error( 'Sync can only be created during initialization.', 2 )
end end
return Syncs.add( opts ).inlet return Syncs.add( opts ).inlet
end end