Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
axkibe committed Mar 1, 2018
1 parent 1e0d867 commit 465e173
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 70 deletions.
12 changes: 2 additions & 10 deletions default-rsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


if not default
then
error( 'default not loaded' )
end

if not default 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 = { }
Expand Down Expand Up @@ -186,7 +179,6 @@ rsync.action = function
(
path
)

if filterP[ path ] then return end

filterP[ path ] = true
Expand Down
17 changes: 4 additions & 13 deletions default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,10 @@ local function check
)
for k, v in pairs( config )
do
if not gauge[k]
if not gauge[ k ]
then
error(
'Parameter "'
.. subtable
.. k
.. '" unknown.'
'Parameter "' .. subtable .. k .. '" unknown.'
.. ' ( if this is not a typo add it to checkgauge )',
level
);
Expand All @@ -405,10 +402,7 @@ local function check
if type( v ) ~= 'table'
then
error(
'Parameter "'
.. subtable
.. k
.. '" must be a table.',
'Parameter "' .. subtable .. k .. '" must be a table.',
level
)
end
Expand All @@ -432,10 +426,7 @@ default.prepare = function

local gauge = config.checkgauge

if not gauge
then
return
end
if not gauge then return end

check( config, gauge, '', level + 1 )
end
Expand Down
70 changes: 23 additions & 47 deletions lsyncd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ readdir = lsyncd.readdir
-- Coping globals to ensure userscripts cannot change this.
--
local log = log

local terminate = terminate

local now = now

local readdir = readdir

--
-- Predeclarations.
Expand Down Expand Up @@ -123,8 +121,8 @@ local settingsSafe
--
-- Array tables error if accessed with a non-number.
--
local Array = ( function( )

local Array = ( function
( )
--
-- Metatable.
--
Expand Down Expand Up @@ -1881,8 +1879,8 @@ end )( )
--
-- A set of exclude patterns.
--
local Excludes = ( function( )

local Excludes = ( function
( )
--
-- Turns a rsync like file pattern to a lua pattern.
-- ( at best it can )
Expand Down Expand Up @@ -2068,7 +2066,6 @@ local Excludes = ( function( )
-- Public interface.
--
return { new = new }

end )( )


Expand All @@ -2077,8 +2074,8 @@ end )( )
--
-- Filters allow excludes and includes
--
local Filters = ( function( )

local Filters = ( function
( )
--
-- Turns a rsync like file pattern to a lua pattern.
-- ( at best it can )
Expand Down Expand Up @@ -2395,18 +2392,12 @@ local Sync = ( function
local alarm = self.config.delay

-- delays at least 1 second
if alarm < 1
then
alarm = 1
end
if alarm < 1 then alarm = 1 end

delay:wait( now( ) + alarm )
end
else
log(
'Delay',
'collected a list'
)
log( 'Delay', 'collected a list' )

local rc = self.config.collect(
InletFactory.dl2el( delay ),
Expand Down Expand Up @@ -2503,11 +2494,7 @@ local Sync = ( function

if isdir then pd = pd..'/' end

log(
'Delay',
'Create creates Create on ',
pd
)
log( 'Delay', 'Create creates Create on ', pd )

delay( self, 'Create', time, pd, nil )
end
Expand Down Expand Up @@ -2876,7 +2863,6 @@ local Sync = ( function
return d
end
end

end

--
Expand Down Expand Up @@ -2975,7 +2961,6 @@ local Sync = ( function
filters = nil,

-- functions

addBlanketDelay = addBlanketDelay,
addExclude = addExclude,
addInitDelay = addInitDelay,
Expand Down Expand Up @@ -3065,7 +3050,6 @@ local Sync = ( function
-- Public interface
--
return { new = new }

end )( )


Expand Down Expand Up @@ -3148,14 +3132,14 @@ local Syncs = ( function
do
if
(
type( k ) ~= 'number' or
verbatim or
cs._verbatim == true
type( k ) ~= 'number'
or verbatim
or cs._verbatim == true
)
and
(
type( cs._merge ) ~= 'table' or
cs._merge[ k ] == true
type( cs._merge ) ~= 'table'
or cs._merge[ k ] == true
)
then
inheritKV( cd, k, v )
Expand All @@ -3166,11 +3150,8 @@ local Syncs = ( function
-- ( for non-verbatim tables )
if cs._verbatim ~= true
then
local n = nil

for k, v in ipairs( cs )
do
n = k
if type( v ) == 'table'
then
inherit( cd, v )
Expand All @@ -3193,10 +3174,7 @@ local Syncs = ( function
)

-- don't merge inheritance controls
if k == '_merge' or k == '_verbatim'
then
return
end
if k == '_merge' or k == '_verbatim' then return end

local dtype = type( cd [ k ] )

Expand All @@ -3212,7 +3190,6 @@ local Syncs = ( function
then
inherit( cd[ k ], v, k == 'exitcodes' )
end

elseif dtype == 'nil'
then
cd[ k ] = v
Expand Down Expand Up @@ -5259,17 +5236,16 @@ end
--
-- Returns an Inlet to that sync.
--
function sync( opts )

if lsyncdStatus ~= 'init' then
error(
'Sync can only be created during initialization.',
2
)
function sync
(
opts
)
if lsyncdStatus ~= 'init'
then
error( 'Sync can only be created during initialization.', 2 )
end

return Syncs.add( opts ).inlet

end


Expand Down

0 comments on commit 465e173

Please sign in to comment.