diff --git a/ChangeLog b/ChangeLog index 0de566b..fa1adec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,15 @@ +2018-??-??: 2.2.3 + change: if the target/targetdir ands with a ':' do not append + a trailing '/' to it, since that would change it from homedir to rootdir! + 2017-02-16: 2.2.2 - fix: checkgauge 'insist' - fix: no partial path exlusion tests - fix: write pid of forked process in pidfile - fix: crash on not reachable target - workaround: - changed back to filter style rsync calling - until https://bugzilla.samba.org/show_bug.cgi?id=12569 + fix: checkgauge 'insist' + fix: no partial path exlusion tests + fix: write pid of forked process in pidfile + fix: crash on not reachable target + workaround: + changed back to filter style rsync calling + until https://bugzilla.samba.org/show_bug.cgi?id=12569 is fixed and released. 2017-01-05: 2.2.1 diff --git a/default-rsync.lua b/default-rsync.lua index 4c1b4a8..7222faf 100644 --- a/default-rsync.lua +++ b/default-rsync.lua @@ -647,11 +647,13 @@ rsync.prepare = function end -- 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 config.target = config.target..'/' end - end diff --git a/default-rsyncssh.lua b/default-rsyncssh.lua index 750e3cb..a82fec6 100644 --- a/default-rsyncssh.lua +++ b/default-rsyncssh.lua @@ -91,10 +91,7 @@ local replaceRsyncFilter = ( path ) - if not path - then - return - end + if not path then return end return( path @@ -161,9 +158,7 @@ rsyncssh.action = function -- Replaces what rsync would consider filter rules by literals -- local function sub( p ) - if not p then - return - end + if not p then return end return p: gsub( '%?', '\\?' ): @@ -195,11 +190,7 @@ rsyncssh.action = function -- adds one path to the filter local function addToFilter( path ) - - if filterP[ path ] - then - return - end + if filterP[ path ] then return end filterP[ path ] = true @@ -372,7 +363,7 @@ rsyncssh.collect = function if rc == 'ok' then - log('Normal', 'Startup of "', agent.source, '" finished: ', exitcode) + log( 'Normal', 'Startup of "', agent.source, '" finished: ', exitcode ) elseif rc == 'again' then if settings('insist') @@ -382,16 +373,16 @@ rsyncssh.collect = function log( 'Error', 'Temporary or permanent failure on startup of "', - agent.source, '". Terminating since "insist" is not set.' + agent.source, '". Terminating since "insist" is not set.' ) terminate( -1 ) -- ERRNO end elseif rc == 'die' then - log( 'Error', 'Failure on startup of "',agent.source,'": ', exitcode ) + log( 'Error', 'Failure on startup of "', agent.source, '": ', exitcode ) else - log( 'Error', 'Unknown exitcode on startup of "', agent.source,': "',exitcode ) + log( 'Error', 'Unknown exitcode on startup of "', agent.source, ': "', exitcode ) rc = 'die' end @@ -431,7 +422,7 @@ rsyncssh.collect = function then log( 'Normal', 'Failure ', agent.etype, ' ', agent.sourcePath, ': ', exitcode ) else - log( 'Error', 'Unknown exitcode ',agent.etype,' ',agent.sourcePath,': ',exitcode ) + log( 'Error', 'Unknown exitcode ', agent.etype,' ', agent.sourcePath,': ', exitcode ) rc = 'die' end @@ -453,18 +444,12 @@ rsyncssh.prepare = function if not config.host then - error( - 'default.rsyncssh needs "host" configured', - level - ) + error( 'default.rsyncssh needs "host" configured', level ) end if not config.targetdir then - error( - 'default.rsyncssh needs "targetdir" configured', - level - ) + error( 'default.rsyncssh needs "targetdir" configured', level ) end -- @@ -472,18 +457,12 @@ rsyncssh.prepare = function -- if config.ssh._computed then - error( - 'please do not use the internal rsync._computed parameter', - level - ) + error( 'please do not use the internal rsync._computed parameter', level ) end if config.maxProcesses ~= 1 then - error( - 'default.rsyncssh must have maxProcesses set to 1.', - level - ) + error( 'default.rsyncssh must have maxProcesses set to 1.', level ) end local cssh = config.ssh; @@ -578,10 +557,11 @@ rsyncssh.prepare = function end -- appends a slash to the targetdir if missing + -- and is not ':' for home dir if string.sub( config.targetdir, -1 ) ~= '/' + and string.sub( config.targetdir, -1 ) ~= ':' then - config.targetdir = - config.targetdir .. '/' + config.targetdir = config.targetdir .. '/' end end diff --git a/lsyncd.h b/lsyncd.h index 6950cbe..9300a09 100644 --- a/lsyncd.h +++ b/lsyncd.h @@ -12,7 +12,7 @@ #define LSYNCD_H // some older machines need this to see pselect -#define _BSD_SOURCE 1 +#define _DEFAULT_SOURCE 1 #define _XOPEN_SOURCE 700 #define _DARWIN_C_SOURCE 1 diff --git a/lsyncd.lua b/lsyncd.lua index 949d3d9..e050451 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -349,7 +349,7 @@ Queue = ( function return nt[ nt.first ] end - + -- -- Returns the last item of the Queue. -- @@ -361,7 +361,7 @@ Queue = ( function return nt[ nt.last ] end - + -- -- Returns the size of the queue. -- @@ -549,7 +549,6 @@ Queue = ( function ) return iterReverse, self, self[ k_nt ].last + 1 end - -- -- Creates a new queue. @@ -1582,10 +1581,7 @@ local InletFactory = ( function if delay.etype ~= 'Move' then - if eu - then - return eu - end + if eu then return eu end local event = { } @@ -1598,10 +1594,7 @@ local InletFactory = ( function return event else -- moves have 2 events - origin and destination - if eu - then - return eu[1], eu[2] - end + if eu then return eu[1], eu[2] end local event = { move = 'Fr' } local event2 = { move = 'To' } @@ -1628,10 +1621,7 @@ local InletFactory = ( function ) local eu = e2d2[ dlist ] - if eu - then - return eu - end + if eu then return eu end local elist = { } @@ -1773,10 +1763,7 @@ local InletFactory = ( function if not f then - error( - 'inlet does not have function "'..func..'"', - 2 - ) + error( 'inlet does not have function "'..func..'"', 2 ) end return function( ... ) @@ -1837,7 +1824,7 @@ end )( ) -- --- A set of exclude patterns +-- A set of exclude patterns. -- local Excludes = ( function( ) @@ -1850,6 +1837,7 @@ local Excludes = ( function( ) p -- the rsync like pattern ) local o = p + p = string.gsub( p, '%%', '%%%%' ) p = string.gsub( p, '%^', '%%^' ) p = string.gsub( p, '%$', '%%$' ) @@ -1873,11 +1861,7 @@ local Excludes = ( function( ) p = '/' .. p; end - log( - 'Exclude', - 'toLuaPattern "', - o, '" = "', p, '"' - ) + log( 'Exclude', 'toLuaPattern "', o, '" = "', p, '"' ) return p end @@ -1908,7 +1892,6 @@ local Excludes = ( function( ) self, -- self pattern -- the pattern to remove ) - if not self.list[ pattern ] then -- already in the list? log( @@ -1930,9 +1913,9 @@ local Excludes = ( function( ) self, plist ) - for _, v in ipairs(plist) + for _, v in ipairs( plist ) do - add(self, v) + add( self, v ) end end @@ -1948,11 +1931,7 @@ local Excludes = ( function( ) if not f then - log( - 'Error', - 'Cannot open exclude file "', file,'": ', - err - ) + log( 'Error', 'Cannot open exclude file "', file,'": ', err ) terminate( -1 ) end @@ -2281,10 +2260,7 @@ local Sync = ( function do local pd = path .. dirname - if isdir - then - pd = pd..'/' - end + if isdir then pd = pd..'/' end log( 'Delay', @@ -3082,13 +3058,16 @@ local Syncs = ( function config.prepare( config, 4 ) end - if not config[ 'source' ] then + if not config[ 'source' ] + then local info = debug.getinfo( 3, 'Sl' ) + log( 'Error', info.short_src,':', info.currentline,': source missing from sync.' ) + terminate( -1 ) end @@ -3104,6 +3083,7 @@ local Syncs = ( function 'Cannot access source directory: ', config.source ) + terminate( -1 ) end @@ -3118,6 +3098,7 @@ local Syncs = ( function and not config.onMove then local info = debug.getinfo( 3, 'Sl' ) + log( 'Error', info.short_src, ':', @@ -3553,14 +3534,12 @@ end)( ) -- local Fsevents = ( function ( ) - -- -- A list indexed by syncs yielding -- the root path the sync is interested in. -- local syncRoots = { } - -- -- Adds a Sync to receive events. -- @@ -4036,8 +4015,6 @@ end )( ) -- local StatusFile = ( function ( ) - - -- -- Timestamp when the status file has been written. --