working on the new rsync config system

This commit is contained in:
Axel Kittenberger 2012-10-06 14:22:08 +02:00
parent 6f90c19196
commit a6b49c8650
5 changed files with 183 additions and 150 deletions

View File

@ -30,12 +30,14 @@ if default.direct then
error('default-direct already loaded')
end
default.direct = {
local direct = { }
--
-- Spawns rsync for a list of events
--
action = function(inlet)
default.direct = direct
--
-- Spawns rsync for a list of events
--
direct.action = function(inlet)
-- gets all events ready for syncing
local event, event2 = inlet.getEvent()
local config = inlet.getConfig()
@ -93,12 +95,12 @@ default.direct = {
log('Warn', 'ignored an event of type "',event.etype, '"')
inlet.discardEvent(event)
end
end,
end
-----
-- Called when collecting a finished child process
--
collect = function(agent, exitcode)
--
-- Called when collecting a finished child process
--
direct.collect = function(agent, exitcode)
local config = agent.config
if not agent.isList and agent.etype == 'Init' then
@ -125,55 +127,40 @@ default.direct = {
-- everything else is just as it is,
-- there is no network to retry something.
return
end,
end
-----
-- Spawns the recursive startup sync
-- (currently) identical to default rsync.
--
init = default.rsync.init,
--
-- Spawns the recursive startup sync
-- (currently) identical to default rsync.
--
direct.init = default.rsync.init
-----
-- Checks the configuration.
--
prepare = function(config)
if not config.target then
error('default.direct needs "target".', 4)
end
--
-- Checks the configuration.
--
direct.prepare = function( config, level )
if config.rsyncOps then
error('did you mean rsyncOpts with "t"?', 4)
end
end,
default.rsync.prepare( config, level + 1 )
-----
-- Default delay is very short.
--
delay = 1,
end
------
-- Let the core not split move events.
--
onMove = true,
--
-- Default delay is very short.
--
direct.delay = 1
-----
-- The rsync binary called.
--
rsync = default.rsync.rsync,
--
-- Let the core not split move events.
--
direct.onMove = true
-----
-- By default do deletes.
--
delete = true,
--
-- By default do deletes.
--
direct.delete = true
-----
-- rsync exit codes
--
rsyncExitCodes = default.rsyncExitCodes,
--
-- On many system multiple disk operations just rather slow down
-- than speed up.
-----
-- On many system multiple disk operations just rather slow down
-- than speed up.
maxProcesses = 1,
}
direct.maxProcesses = 1

View File

@ -296,8 +296,6 @@ rsync.prepare = function(
skipTarget -- used by rsyncssh, do not check for target
)
level = level or 4
--
-- First let default.prepare test the checkgauge
--
@ -363,11 +361,42 @@ rsync.prepare = function(
)
end
--
-- computes the rsync arguments into one list
local rsync = config.rsync;
--
local crsync = config.rsync;
rsync._computed = { true }
local computed = rsync._computed
--
-- everything implied by archive = true
--
local archiveFlags = {
recursive = true,
links = true,
perms = true,
times = true,
group = true,
owner = true,
devices = true,
specials = true,
hard_links = false,
acls = false,
xattrs = false,
}
--
-- if archive given the implications are filled in
--
if crsync.archive then
for k, v in pairs( archiveFlags ) do
if crsync[ k ] == nil then
crsync[ k ] = v
end
end
end
crsync._computed = { true }
local computed = crsync._computed
local computedN = 1
local shortFlags = {
@ -401,27 +430,42 @@ rsync.prepare = function(
local shorts = { '-' }
local shortsN = 2
if config.rsync._extra then
for k, v in ipairs( config.rsync._extra ) do
if crsync._extra then
for k, v in ipairs( crsync._extra ) do
computed[ computedN ] = v
computedN = computedN + 1
end
end
for k, flag in pairs( shortFlags ) do
if config.rsync[k] then
if crsync[ k ] then
shorts[ shortsN ] = flag
shortsN = shortsN + 1
end
end
if config.rsync.rsh then
computed[ computedN ] = '--rsh=' + config.rsync.rsh
if crsync.devices and crsync.specials then
shorts[ shortsN ] = 'D'
shortsN = shortsN + 1
else
if crsync.devices then
computed[ computedN ] = '--devices'
computedN = computedN + 1
end
if config.rsync.rsync_path then
computed[ computedN ] = '--rsync-path=' + config.rsync.rsync_path
if crsync.specials then
computed[ computedN ] = '--specials'
computedN = computedN + 1
end
end
if crsync.rsh then
computed[ computedN ] = '--rsh=' + crsync.rsh
computedN = computedN + 1
end
if crsync.rsync_path then
computed[ computedN ] = '--rsync-path=' + crsync.rsync_path
computedN = computedN + 1
end

View File

@ -45,6 +45,8 @@ rsyncssh.checkgauge = {
-- rsyncssh users host and targetdir
host = true,
targetdir = true,
sshExitCodes = true,
rsyncExitCodes = true,
-- ssh settings
ssh = {
@ -254,9 +256,9 @@ end
--
-- checks the configuration.
--
rsyncssh.prepare = function( config )
rsyncssh.prepare = function( config, level )
default.rsync.prepare( config, 5, true )
default.rsync.prepare( config, level + 1, true )
if not config.host then
error('default.rsyncssh needs "host" configured', 4)

View File

@ -352,6 +352,6 @@ default.prepare = function( config, level )
return
end
check( config, gauge, '', level or 2 )
check( config, gauge, '', level + 1 )
end

View File

@ -2286,7 +2286,7 @@ local Syncs = ( function( )
if type( config.prepare ) == 'function' then
-- prepare is given a writeable copy of config
config.prepare( config )
config.prepare( config, 4 )
end