mirror of https://github.com/octoleo/lsyncd.git
style cleanup
This commit is contained in:
parent
fa3028321b
commit
5d2126a472
81
lsyncd.lua
81
lsyncd.lua
|
@ -1558,12 +1558,15 @@ local Sync = ( function( )
|
||||||
exitcode
|
exitcode
|
||||||
)
|
)
|
||||||
|
|
||||||
if rc == 'die' then
|
if rc == 'die'
|
||||||
log( 'Error', 'Critical exitcode.' );
|
then
|
||||||
|
log( 'Error', 'Critical exitcode.' )
|
||||||
|
|
||||||
terminate( -1 )
|
terminate( -1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
if rc ~= 'again' then
|
if rc ~= 'again'
|
||||||
|
then
|
||||||
-- if its active again the collecter restarted the event
|
-- if its active again the collecter restarted the event
|
||||||
removeDelay( self, delay )
|
removeDelay( self, delay )
|
||||||
log(
|
log(
|
||||||
|
@ -2214,15 +2217,14 @@ local Syncs = ( function( )
|
||||||
-- Recurvely inherits a source table to a destionation table
|
-- Recurvely inherits a source table to a destionation table
|
||||||
-- copying all keys from source.
|
-- copying all keys from source.
|
||||||
--
|
--
|
||||||
-- table copy source ( cs )
|
|
||||||
-- table copy destination ( cd )
|
|
||||||
-- forced verbatim for e.g. exitcodes ( verbatim )
|
|
||||||
--
|
|
||||||
-- All entries with integer keys are inherited as additional
|
-- All entries with integer keys are inherited as additional
|
||||||
-- sources for non-verbatim tables
|
-- sources for non-verbatim tables
|
||||||
--
|
--
|
||||||
local function inherit( cd, cs, verbatim )
|
local function inherit(
|
||||||
|
cd, -- table copy destination
|
||||||
|
cs, -- table copy source
|
||||||
|
verbatim -- forced verbatim ( for e.g. 'exitcodes' )
|
||||||
|
)
|
||||||
-- First copies all entries with non-integer keys.
|
-- First copies all entries with non-integer keys.
|
||||||
--
|
--
|
||||||
-- Tables are merged; already present keys are not
|
-- Tables are merged; already present keys are not
|
||||||
|
@ -2230,7 +2232,8 @@ local Syncs = ( function( )
|
||||||
--
|
--
|
||||||
-- For verbatim tables integer keys are treated like
|
-- For verbatim tables integer keys are treated like
|
||||||
-- non-integer keys
|
-- non-integer keys
|
||||||
for k, v in pairs( cs ) do
|
for k, v in pairs( cs )
|
||||||
|
do
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
type( k ) ~= 'number' or
|
type( k ) ~= 'number' or
|
||||||
|
@ -2249,12 +2252,15 @@ local Syncs = ( function( )
|
||||||
|
|
||||||
-- recursevely inherits all integer keyed tables
|
-- recursevely inherits all integer keyed tables
|
||||||
-- ( for non-verbatim tables )
|
-- ( for non-verbatim tables )
|
||||||
if cs._verbatim ~= true then
|
if cs._verbatim ~= true
|
||||||
|
then
|
||||||
local n = nil
|
local n = nil
|
||||||
for k, v in ipairs( cs ) do
|
|
||||||
|
for k, v in ipairs( cs )
|
||||||
|
do
|
||||||
n = k
|
n = k
|
||||||
if type( v ) == 'table' then
|
if type( v ) == 'table'
|
||||||
|
then
|
||||||
inherit( cd, v )
|
inherit( cd, v )
|
||||||
else
|
else
|
||||||
cd[ #cd + 1 ] = v
|
cd[ #cd + 1 ] = v
|
||||||
|
@ -2267,18 +2273,25 @@ local Syncs = ( function( )
|
||||||
--
|
--
|
||||||
-- Helper to inherit. Inherits one key.
|
-- Helper to inherit. Inherits one key.
|
||||||
--
|
--
|
||||||
inheritKV = function( cd, k, v )
|
inheritKV =
|
||||||
|
function(
|
||||||
|
cd, -- table copy destination
|
||||||
|
k, -- key
|
||||||
|
v -- value
|
||||||
|
)
|
||||||
|
|
||||||
-- don't merge inheritance controls
|
-- don't merge inheritance controls
|
||||||
if k == '_merge' or k == '_verbatim' then
|
if k == '_merge' or k == '_verbatim'
|
||||||
|
then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local dtype = type( cd [ k ] )
|
local dtype = type( cd [ k ] )
|
||||||
|
|
||||||
if type( v ) == 'table' then
|
if type( v ) == 'table'
|
||||||
|
then
|
||||||
if dtype == 'nil' then
|
if dtype == 'nil'
|
||||||
|
then
|
||||||
cd[ k ] = { }
|
cd[ k ] = { }
|
||||||
inherit( cd[ k ], v, k == 'exitcodes' )
|
inherit( cd[ k ], v, k == 'exitcodes' )
|
||||||
elseif
|
elseif
|
||||||
|
@ -2288,10 +2301,10 @@ local Syncs = ( function( )
|
||||||
inherit( cd[ k ], v, k == 'exitcodes' )
|
inherit( cd[ k ], v, k == 'exitcodes' )
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif dtype == 'nil' then
|
elseif dtype == 'nil'
|
||||||
|
then
|
||||||
cd[ k ] = v
|
cd[ k ] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -2302,14 +2315,16 @@ local Syncs = ( function( )
|
||||||
|
|
||||||
-- workaround for backwards compatibility
|
-- workaround for backwards compatibility
|
||||||
-- FIXME: remove when dropping that
|
-- FIXME: remove when dropping that
|
||||||
if settings ~= settingsSafe then
|
if settings ~= settingsSafe
|
||||||
|
then
|
||||||
log(
|
log(
|
||||||
'Warn',
|
'Warn',
|
||||||
'settings = { ... } is deprecated.\n'..
|
'settings = { ... } is deprecated.\n'..
|
||||||
' please use settings{ ... } (without the equal sign)'
|
' please use settings{ ... } (without the equal sign)'
|
||||||
)
|
)
|
||||||
|
|
||||||
for k, v in pairs( settings ) do
|
for k, v in pairs( settings )
|
||||||
|
do
|
||||||
uSettings[ k ] = v
|
uSettings[ k ] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2336,15 +2351,19 @@ local Syncs = ( function( )
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Lets settings override these values.
|
-- Lets settings override these values.
|
||||||
for _, v in ipairs( inheritSettings ) do
|
for _, v in ipairs( inheritSettings )
|
||||||
if uSettings[ v ] then
|
do
|
||||||
|
if uSettings[ v ]
|
||||||
|
then
|
||||||
config[ v ] = uSettings[ v ]
|
config[ v ] = uSettings[ v ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Lets commandline override these values.
|
-- Lets commandline override these values.
|
||||||
for _, v in ipairs( inheritSettings ) do
|
for _, v in ipairs( inheritSettings )
|
||||||
if clSettings[ v ] then
|
do
|
||||||
|
if clSettings[ v ]
|
||||||
|
then
|
||||||
config[ v ] = clSettings[ v ]
|
config[ v ] = clSettings[ v ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2353,11 +2372,10 @@ local Syncs = ( function( )
|
||||||
-- lets the userscript 'prepare' function
|
-- lets the userscript 'prepare' function
|
||||||
-- check and complete the config
|
-- check and complete the config
|
||||||
--
|
--
|
||||||
if type( config.prepare ) == 'function' then
|
if type( config.prepare ) == 'function'
|
||||||
|
then
|
||||||
-- prepare is given a writeable copy of config
|
-- prepare is given a writeable copy of config
|
||||||
config.prepare( config, 4 )
|
config.prepare( config, 4 )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not config[ 'source' ] then
|
if not config[ 'source' ] then
|
||||||
|
@ -2375,7 +2393,8 @@ local Syncs = ( function( )
|
||||||
--
|
--
|
||||||
local realsrc = lsyncd.realdir( config.source )
|
local realsrc = lsyncd.realdir( config.source )
|
||||||
|
|
||||||
if not realsrc then
|
if not realsrc
|
||||||
|
then
|
||||||
log(
|
log(
|
||||||
'Error',
|
'Error',
|
||||||
'Cannot access source directory: ',
|
'Cannot access source directory: ',
|
||||||
|
|
Loading…
Reference in New Issue