mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-11-15 01:24:03 +00:00
cleanups, tests adaption
This commit is contained in:
parent
62517c2922
commit
b030d4b898
@ -15,20 +15,11 @@
|
||||
--
|
||||
--
|
||||
|
||||
if not default
|
||||
then
|
||||
error( 'default not loaded' );
|
||||
end
|
||||
if not default then error( 'default not loaded' ); end
|
||||
|
||||
if not default.rsync
|
||||
then
|
||||
error( 'default.rsync not loaded' );
|
||||
end
|
||||
if not default.rsync then error( 'default.rsync not loaded' ); end
|
||||
|
||||
if default.rsyncssh
|
||||
then
|
||||
error( 'default-rsyncssh already loaded' );
|
||||
end
|
||||
if default.rsyncssh then error( 'default-rsyncssh already loaded' ); end
|
||||
|
||||
--
|
||||
-- rsyncssh extends default.rsync
|
||||
@ -360,7 +351,7 @@ rsyncssh.collect = function
|
||||
|
||||
if not agent.isList and agent.etype == 'Init'
|
||||
then
|
||||
local rc = config.rsyncExitCodes[exitcode]
|
||||
local rc = config.rsyncExitCodes[ exitcode ]
|
||||
|
||||
if rc == 'ok'
|
||||
then
|
||||
@ -570,7 +561,7 @@ rsyncssh.exitcodes = false
|
||||
--
|
||||
-- rsync exit codes
|
||||
--
|
||||
rsyncssh.rsyncExitCodes = default.rsync.exitCodes
|
||||
rsyncssh.rsyncExitCodes = default.rsync.exitcodes
|
||||
|
||||
--
|
||||
-- Exitcodes of ssh and what to do.
|
||||
|
@ -36,8 +36,6 @@ local assignable =
|
||||
{
|
||||
dpos = true,
|
||||
etype = true,
|
||||
path = true,
|
||||
path2 = true,
|
||||
status = true,
|
||||
}
|
||||
|
||||
|
@ -183,15 +183,9 @@ local function collect
|
||||
|
||||
alarm = now() + alarm
|
||||
|
||||
for _, d in ipairs( delay )
|
||||
do
|
||||
d:wait( alarm )
|
||||
end
|
||||
for _, d in ipairs( delay ) do d:wait( alarm ) end
|
||||
else
|
||||
for _, d in ipairs( delay )
|
||||
do
|
||||
removeDelay( self, d )
|
||||
end
|
||||
for _, d in ipairs( delay ) do removeDelay( self, d ) end
|
||||
end
|
||||
|
||||
log( 'Delay','Finished list = ',exitcode )
|
||||
@ -368,10 +362,7 @@ local function delay
|
||||
' event.'
|
||||
)
|
||||
|
||||
if #self.delays > 0
|
||||
then
|
||||
stack( self.delays:last( ), nd )
|
||||
end
|
||||
if #self.delays > 0 then stack( self.delays:last( ), nd ) end
|
||||
|
||||
nd.dpos = self.delays:push( nd )
|
||||
|
||||
@ -528,10 +519,7 @@ local function getDelays
|
||||
do
|
||||
local tr = true
|
||||
|
||||
if test
|
||||
then
|
||||
tr = test( InletFactory.d2e( d ) )
|
||||
end
|
||||
if test then tr = test( InletFactory.d2e( d ) ) end
|
||||
|
||||
if tr == 'break' then break end
|
||||
|
||||
@ -860,10 +848,10 @@ local function new
|
||||
-- since this way it will raise any issues of mindelay or delay
|
||||
-- not being numbers as well
|
||||
|
||||
if not ( config.mindelay >= config.delay )
|
||||
if not ( config.mindelay <= config.delay )
|
||||
then
|
||||
error(
|
||||
'mindelay (= '..config.mindelay.. ') must be larger '..
|
||||
'mindelay (= '..config.mindelay.. ') must be smaller '..
|
||||
'or equal than delay (= '..config.delay..')',
|
||||
level
|
||||
)
|
||||
|
@ -16,9 +16,13 @@ churn( srcdir, 100, true )
|
||||
local logs = { }
|
||||
local pid = spawn(
|
||||
'./lsyncd',
|
||||
'-nodaemon',
|
||||
'-delay', '5',
|
||||
'-rsync', srcdir, trgdir,
|
||||
'-c',
|
||||
'sync{ '
|
||||
.. 'default.rsync, '
|
||||
.. 'delay = 5, '
|
||||
.. 'source = "'..srcdir..'", '
|
||||
.. 'target = "'..trgdir..'" '
|
||||
.. '}',
|
||||
table.unpack( logs )
|
||||
)
|
||||
|
||||
@ -26,7 +30,7 @@ cwriteln( 'waiting for Lsyncd to startup' )
|
||||
|
||||
posix.sleep( 1 )
|
||||
|
||||
churn( srcdir, 500, false )
|
||||
churn( srcdir, 100, false )
|
||||
|
||||
cwriteln( 'waiting for Lsyncd to finish its jobs.' )
|
||||
|
||||
|
@ -21,20 +21,21 @@ logs = { '-log', 'Delay' }
|
||||
|
||||
local pid = spawn(
|
||||
'./lsyncd',
|
||||
'-nodaemon',
|
||||
'-delay',
|
||||
'5',
|
||||
'-rsyncssh',
|
||||
srcdir,
|
||||
'localhost',
|
||||
trgdir,
|
||||
'-c',
|
||||
'sync{ '
|
||||
.. 'default.rsyncssh, '
|
||||
.. 'delay = 5, '
|
||||
.. 'source = "'..srcdir..'", '
|
||||
.. 'host = "localhost", '
|
||||
.. 'targetdir = "'..trgdir..'" '
|
||||
.. '}',
|
||||
table.unpack(logs)
|
||||
)
|
||||
|
||||
cwriteln( 'waiting for Lsyncd to startup' )
|
||||
posix.sleep( 1 )
|
||||
|
||||
churn( srcdir, 150, false )
|
||||
churn( srcdir, 100, false )
|
||||
|
||||
cwriteln( 'waiting for Lsyncd to finish its jobs.' )
|
||||
posix.sleep( 10 )
|
||||
|
Loading…
Reference in New Issue
Block a user