preparing 2.2.3

This commit is contained in:
Axel Kittenberger 2018-03-09 10:04:48 +01:00
commit 8904710acb
6 changed files with 710 additions and 601 deletions

View File

@ -1,6 +1,13 @@
2018-??-??: 2.2.3
enhaencement: supporting includes with new filter and filterFrom options
change: if the target/targetdir ands with a ':' do not append
a trailing '/' to it, since that would change it from homedir to rootdir!
add: example for Amazon S3 Bucket (Daniel Miranda)
fix: setting stdout/stderr to linebuffer mode.
2017-02-16: 2.2.2 2017-02-16: 2.2.2
fix: checkgauge 'insist' fix: checkgauge 'insist'
fix: no partial path exclusion tests fix: no partial path exlusion tests
fix: write pid of forked process in pidfile fix: write pid of forked process in pidfile
fix: crash on not reachable target fix: crash on not reachable target
workaround: workaround:

View File

@ -16,16 +16,9 @@
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if not default if not default then error( 'default not loaded' ) end
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 = { } local rsync = { }
@ -49,6 +42,8 @@ rsync.checkgauge = {
delete = true, delete = true,
exclude = true, exclude = true,
excludeFrom = true, excludeFrom = true,
filter = true,
filterFrom = true,
target = true, target = true,
rsync = { rsync = {
@ -117,28 +112,6 @@ local eventNotInitBlank =
end end
--
-- Replaces what rsync would consider filter rules by literals.
--
local replaceRsyncFilter =
function
(
path
)
if not path
then
return
end
return(
path
:gsub( '%?', '\\?' )
:gsub( '%*', '\\*' )
:gsub( '%[', '\\[' )
)
end
-- --
-- Spawns rsync for a list of events -- Spawns rsync for a list of events
-- --
@ -161,10 +134,11 @@ rsync.action = function
-- --
-- Replaces what rsync would consider filter rules by literals -- Replaces what rsync would consider filter rules by literals
-- --
local function sub( p ) local function sub
if not p then (
return p -- pattern
end )
if not p then return end
return p: return p:
gsub( '%?', '\\?' ): gsub( '%?', '\\?' ):
@ -179,8 +153,14 @@ rsync.action = function
-- Deletes create multi match patterns -- Deletes create multi match patterns
-- --
local paths = elist.getPaths( local paths = elist.getPaths(
function( etype, path1, path2 ) function
if string.byte( path1, -1 ) == 47 and etype == 'Delete' then (
etype, -- event type
path1, -- path
path2 -- path to for move events
)
if string.byte( path1, -1 ) == 47 and etype == 'Delete'
then
return sub( path1 )..'***', sub( path2 ) return sub( path1 )..'***', sub( path2 )
else else
return sub( path1 ), sub( path2 ) return sub( path1 ), sub( path2 )
@ -195,11 +175,11 @@ rsync.action = function
local filterP = { } local filterP = { }
-- adds one path to the filter -- adds one path to the filter
local function addToFilter( path ) local function addToFilter
(
if filterP[ path ] then path
return )
end if filterP[ path ] then return end
filterP[ path ] = true filterP[ path ] = true
@ -211,21 +191,21 @@ rsync.action = function
-- rsync needs to have entries for all steps in the path, -- rsync needs to have entries for all steps in the path,
-- so the file for example d1/d2/d3/f1 needs following filters: -- so the file for example d1/d2/d3/f1 needs following filters:
-- 'd1/', 'd1/d2/', 'd1/d2/d3/' and 'd1/d2/d3/f1' -- 'd1/', 'd1/d2/', 'd1/d2/d3/' and 'd1/d2/d3/f1'
for _, path in ipairs( paths ) do for _, path in ipairs( paths )
do
if path and path ~= '' then if path and path ~= ''
then
addToFilter(path) addToFilter( path )
local pp = string.match( path, '^(.*/)[^/]+/?' ) local pp = string.match( path, '^(.*/)[^/]+/?' )
while pp do while pp
addToFilter(pp) do
addToFilter( pp )
pp = string.match( pp, '^(.*/)[^/]+/?' ) pp = string.match( pp, '^(.*/)[^/]+/?' )
end end
end end
end end
log( log(
@ -334,6 +314,8 @@ rsync.init = function
local excludes = inlet.getExcludes( ) local excludes = inlet.getExcludes( )
local filters = inlet.hasFilters( ) and inlet.getFilters( )
local delete = nil local delete = nil
local target = config.target local target = config.target
@ -354,9 +336,9 @@ rsync.init = function
delete = { '--delete', '--ignore-errors' } delete = { '--delete', '--ignore-errors' }
end end
if #excludes == 0 if not filters and #excludes == 0
then then
-- starts rsync without any excludes -- starts rsync without any filters or excludes
log( log(
'Normal', 'Normal',
'recursive startup rsync: ', 'recursive startup rsync: ',
@ -375,7 +357,8 @@ rsync.init = function
target target
) )
else elseif not filters
then
-- starts rsync providing an exclusion list -- starts rsync providing an exclusion list
-- on stdin -- on stdin
local exS = table.concat( excludes, '\n' ) local exS = table.concat( excludes, '\n' )
@ -401,6 +384,32 @@ rsync.init = function
config.source, config.source,
target target
) )
else
-- starts rsync providing a filter list
-- on stdin
local fS = table.concat( filters, '\n' )
log(
'Normal',
'recursive startup rsync: ',
config.source,
' -> ',
target,
' filtering\n',
fS
)
spawn(
event,
config.rsync.binary,
'<', fS,
'--filter=. -',
delete,
config.rsync._computed,
'-r',
config.source,
target
)
end end
end end
@ -647,11 +656,13 @@ rsync.prepare = function
end end
-- appends a / to target if not present -- appends a / to target if not present
if not skipTarget and string.sub(config.target, -1) ~= '/' -- and not a ':' for home dir.
if not skipTarget
and string.sub( config.target, -1 ) ~= '/'
and string.sub( config.target, -1 ) ~= ':'
then then
config.target = config.target..'/' config.target = config.target..'/'
end end
end end

View File

@ -91,10 +91,7 @@ local replaceRsyncFilter =
( (
path path
) )
if not path if not path then return end
then
return
end
return( return(
path path
@ -161,9 +158,7 @@ rsyncssh.action = function
-- Replaces what rsync would consider filter rules by literals -- Replaces what rsync would consider filter rules by literals
-- --
local function sub( p ) local function sub( p )
if not p then if not p then return end
return
end
return p: return p:
gsub( '%?', '\\?' ): gsub( '%?', '\\?' ):
@ -195,11 +190,7 @@ rsyncssh.action = function
-- adds one path to the filter -- adds one path to the filter
local function addToFilter( path ) local function addToFilter( path )
if filterP[ path ] then return end
if filterP[ path ]
then
return
end
filterP[ path ] = true filterP[ path ] = true
@ -372,7 +363,7 @@ rsyncssh.collect = function
if rc == 'ok' if rc == 'ok'
then then
log('Normal', 'Startup of "', agent.source, '" finished: ', exitcode) log( 'Normal', 'Startup of "', agent.source, '" finished: ', exitcode )
elseif rc == 'again' elseif rc == 'again'
then then
if settings('insist') if settings('insist')
@ -389,9 +380,9 @@ rsyncssh.collect = function
end end
elseif rc == 'die' elseif rc == 'die'
then then
log( 'Error', 'Failure on startup of "',agent.source,'": ', exitcode ) log( 'Error', 'Failure on startup of "', agent.source, '": ', exitcode )
else else
log( 'Error', 'Unknown exitcode on startup of "', agent.source,': "',exitcode ) log( 'Error', 'Unknown exitcode on startup of "', agent.source, ': "', exitcode )
rc = 'die' rc = 'die'
end end
@ -431,7 +422,7 @@ rsyncssh.collect = function
then then
log( 'Normal', 'Failure ', agent.etype, ' ', agent.sourcePath, ': ', exitcode ) log( 'Normal', 'Failure ', agent.etype, ' ', agent.sourcePath, ': ', exitcode )
else else
log( 'Error', 'Unknown exitcode ',agent.etype,' ',agent.sourcePath,': ',exitcode ) log( 'Error', 'Unknown exitcode ', agent.etype,' ', agent.sourcePath,': ', exitcode )
rc = 'die' rc = 'die'
end end
@ -453,18 +444,12 @@ rsyncssh.prepare = function
if not config.host if not config.host
then then
error( error( 'default.rsyncssh needs "host" configured', level )
'default.rsyncssh needs "host" configured',
level
)
end end
if not config.targetdir if not config.targetdir
then then
error( error( 'default.rsyncssh needs "targetdir" configured', level )
'default.rsyncssh needs "targetdir" configured',
level
)
end end
-- --
@ -472,18 +457,12 @@ rsyncssh.prepare = function
-- --
if config.ssh._computed if config.ssh._computed
then then
error( error( 'please do not use the internal rsync._computed parameter', level )
'please do not use the internal rsync._computed parameter',
level
)
end end
if config.maxProcesses ~= 1 if config.maxProcesses ~= 1
then then
error( error( 'default.rsyncssh must have maxProcesses set to 1.', level )
'default.rsyncssh must have maxProcesses set to 1.',
level
)
end end
local cssh = config.ssh; local cssh = config.ssh;
@ -578,10 +557,11 @@ rsyncssh.prepare = function
end end
-- appends a slash to the targetdir if missing -- appends a slash to the targetdir if missing
-- and is not ':' for home dir
if string.sub( config.targetdir, -1 ) ~= '/' if string.sub( config.targetdir, -1 ) ~= '/'
and string.sub( config.targetdir, -1 ) ~= ':'
then then
config.targetdir = config.targetdir = config.targetdir .. '/'
config.targetdir .. '/'
end end
end end

View File

@ -388,13 +388,10 @@ local function check
) )
for k, v in pairs( config ) for k, v in pairs( config )
do do
if not gauge[k] if not gauge[ k ]
then then
error( error(
'Parameter "' 'Parameter "' .. subtable .. k .. '" unknown.'
.. subtable
.. k
.. '" unknown.'
.. ' ( if this is not a typo add it to checkgauge )', .. ' ( if this is not a typo add it to checkgauge )',
level level
); );
@ -405,10 +402,7 @@ local function check
if type( v ) ~= 'table' if type( v ) ~= 'table'
then then
error( error(
'Parameter "' 'Parameter "' .. subtable .. k .. '" must be a table.',
.. subtable
.. k
.. '" must be a table.',
level level
) )
end end
@ -432,10 +426,7 @@ default.prepare = function
local gauge = config.checkgauge local gauge = config.checkgauge
if not gauge if not gauge then return end
then
return
end
check( config, gauge, '', level + 1 ) check( config, gauge, '', level + 1 )
end end

View File

@ -12,7 +12,7 @@
#define LSYNCD_H #define LSYNCD_H
// some older machines need this to see pselect // some older machines need this to see pselect
#define _BSD_SOURCE 1 #define _DEFAULT_SOURCE 1
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#define _DARWIN_C_SOURCE 1 #define _DARWIN_C_SOURCE 1

File diff suppressed because it is too large Load Diff