mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 09:04:05 +00:00
lifting some inline funcs
This commit is contained in:
parent
83c6436e84
commit
7bae036f03
@ -106,51 +106,44 @@ rsync.checkgauge = {
|
||||
|
||||
|
||||
--
|
||||
-- Spawns rsync for a list of events
|
||||
-- Returns true for non Init and Blanket events.
|
||||
--
|
||||
-- Exclusions are already handled by not having
|
||||
-- events for them.
|
||||
--
|
||||
rsync.action = function
|
||||
(
|
||||
inlet
|
||||
)
|
||||
--
|
||||
-- gets all events ready for syncing
|
||||
--
|
||||
local elist = inlet.getEvents(
|
||||
local eventNotInitBlank =
|
||||
function
|
||||
(
|
||||
event
|
||||
)
|
||||
return event.etype ~= 'Init' and event.etype ~= 'Blanket'
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--
|
||||
-- Replaces what rsync would consider filter rules by literals
|
||||
-- Replaces what rsync would consider filter rules by literals.
|
||||
--
|
||||
local function sub
|
||||
local replaceRsyncFilter =
|
||||
function
|
||||
(
|
||||
p
|
||||
path
|
||||
)
|
||||
if not p
|
||||
if not path
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
return p:
|
||||
gsub( '%?', '\\?' ):
|
||||
gsub( '%*', '\\*' ):
|
||||
gsub( '%[', '\\[' )
|
||||
return(
|
||||
path
|
||||
:gsub( '%?', '\\?' )
|
||||
:gsub( '%*', '\\*' )
|
||||
:gsub( '%[', '\\[' )
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Gets the list of paths for the event list
|
||||
-- Mutates paths for rsync filter rules,
|
||||
-- changes deletes to multi path patterns
|
||||
--
|
||||
-- Deletes create multi match patterns
|
||||
--
|
||||
local paths = elist.getPaths(
|
||||
local pathMutator =
|
||||
function
|
||||
(
|
||||
etype,
|
||||
@ -160,26 +153,37 @@ rsync.action = function
|
||||
if string.byte( path1, -1 ) == 47
|
||||
and etype == 'Delete'
|
||||
then
|
||||
return sub( path1 )..'***', sub( path2 )
|
||||
return replaceRsyncFilter( path1 ) .. '***', replaceRsyncFilter( path2 )
|
||||
else
|
||||
return sub( path1 ), sub( path2 )
|
||||
return replaceRsyncFilter( path1 ), replaceRsyncFilter( path2 )
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
||||
--
|
||||
-- stores all filters by integer index
|
||||
-- Spawns rsync for a list of events
|
||||
--
|
||||
-- Exclusions are already handled by not having
|
||||
-- events for them.
|
||||
--
|
||||
rsync.action = function
|
||||
(
|
||||
inlet
|
||||
)
|
||||
-- gets all events ready for syncing
|
||||
local elist = inlet.getEvents( eventNotInitBlank )
|
||||
|
||||
-- gets the list of paths for the event list
|
||||
-- deletes create multi match patterns
|
||||
local paths = elist.getPaths( pathMutator )
|
||||
|
||||
-- stores all filters by integer index
|
||||
local filterI = { }
|
||||
|
||||
--
|
||||
-- Stores all filters with path index
|
||||
--
|
||||
-- stores all filters with path index
|
||||
local filterP = { }
|
||||
|
||||
--
|
||||
-- Adds one path to the filter
|
||||
--
|
||||
-- adds one path to the filter
|
||||
local function addToFilter
|
||||
(
|
||||
path
|
||||
@ -218,6 +222,7 @@ rsync.action = function
|
||||
end
|
||||
|
||||
local filterS = table.concat( filterI, '\n' )
|
||||
|
||||
local filter0 = table.concat( filterI, '\000' )
|
||||
|
||||
log(
|
||||
@ -250,7 +255,6 @@ rsync.action = function
|
||||
config.source,
|
||||
config.target
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -253,8 +253,12 @@ rsyncssh.collect = function
|
||||
then
|
||||
log( 'Normal', 'Retrying startup of "', agent.source, '": ', exitcode )
|
||||
else
|
||||
log( 'Error', 'Temporary or permanent failure on startup of "',
|
||||
agent.source, '". Terminating since "insist" is not set.' );
|
||||
log(
|
||||
'Error',
|
||||
'Temporary or permanent failure on startup of "',
|
||||
agent.source, '". Terminating since "insist" is not set.'
|
||||
)
|
||||
|
||||
terminate( -1 ) -- ERRNO
|
||||
end
|
||||
elseif rc == 'die'
|
||||
|
Loading…
Reference in New Issue
Block a user