mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-02-08 22:58:27 +00:00
fix fsevents for real; code beautify
This commit is contained in:
parent
28d1ea4627
commit
13861fcadc
378
lsyncd.lua
378
lsyncd.lua
@ -1928,7 +1928,7 @@ local Inotify = (function()
|
|||||||
|
|
||||||
for sync, root in pairs(syncRoots) do repeat
|
for sync, root in pairs(syncRoots) do repeat
|
||||||
local relative = splitPath(path, root)
|
local relative = splitPath(path, root)
|
||||||
local relative2
|
local relative2 = nil
|
||||||
if path2 then
|
if path2 then
|
||||||
relative2 = splitPath(path2, root)
|
relative2 = splitPath(path2, root)
|
||||||
end
|
end
|
||||||
@ -1940,26 +1940,24 @@ local Inotify = (function()
|
|||||||
-- makes a copy of etype to possibly change it
|
-- makes a copy of etype to possibly change it
|
||||||
local etyped = etype
|
local etyped = etype
|
||||||
if etyped == 'Move' then
|
if etyped == 'Move' then
|
||||||
if not relative then
|
if not relative2 then
|
||||||
log("Normal", "Transformed Move to Create for ",
|
log('Normal', 'Transformed Move to Create for ', sync.config.name)
|
||||||
sync.config.name)
|
|
||||||
etyped = 'Create'
|
etyped = 'Create'
|
||||||
elseif not relative2 then
|
elseif not relative then
|
||||||
relative = relative2
|
relative = relative2
|
||||||
relative2 = nil
|
relative2 = nil
|
||||||
log("Normal", "Transformed Move to Delete for ",
|
log('Normal', 'Transformed Move to Delete for ', sync.config.name)
|
||||||
sync.config.name)
|
|
||||||
etyped = 'Delete'
|
etyped = 'Delete'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sync:delay(etyped, time, relative, relative2)
|
sync:delay(etyped, time, relative, relative2)
|
||||||
|
|
||||||
if isdir then
|
if isdir then
|
||||||
if etyped == "Create" then
|
if etyped == 'Create' then
|
||||||
addWatch(path, true, sync, time)
|
addWatch(path, true, sync, time)
|
||||||
elseif etyped == "Delete" then
|
elseif etyped == 'Delete' then
|
||||||
removeWatch(path, true)
|
removeWatch(path, true)
|
||||||
elseif etyped == "Move" then
|
elseif etyped == 'Move' then
|
||||||
removeWatch(path, false)
|
removeWatch(path, false)
|
||||||
addWatch(path2, true, sync, time)
|
addWatch(path2, true, sync, time)
|
||||||
end
|
end
|
||||||
@ -1971,9 +1969,9 @@ local Inotify = (function()
|
|||||||
-- Writes a status report about inotifies to a filedescriptor
|
-- Writes a status report about inotifies to a filedescriptor
|
||||||
--
|
--
|
||||||
local function statusReport(f)
|
local function statusReport(f)
|
||||||
f:write("Inotify watching ",wdpaths:size()," directories\n")
|
f:write('Inotify watching ',wdpaths:size(),' directories\n')
|
||||||
for wd, path in wdpaths:walk() do
|
for wd, path in wdpaths:walk() do
|
||||||
f:write(" ",wd,": ",path,"\n")
|
f:write(' ',wd,': ',path,'\n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2004,7 +2002,7 @@ local Fsevents = (function()
|
|||||||
-- @param dir dir to watch
|
-- @param dir dir to watch
|
||||||
--
|
--
|
||||||
local function addSync(sync, dir)
|
local function addSync(sync, dir)
|
||||||
if syncRoots[sync] then error("duplicate sync in Fanotify.addSync()") end
|
if syncRoots[sync] then error('duplicate sync in Fanotify.addSync()') end
|
||||||
syncRoots[sync] = dir
|
syncRoots[sync] = dir
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2041,10 +2039,10 @@ local Fsevents = (function()
|
|||||||
-- possibly change etype for this iteration only
|
-- possibly change etype for this iteration only
|
||||||
local etyped = etype
|
local etyped = etype
|
||||||
if etyped == 'Move' then
|
if etyped == 'Move' then
|
||||||
if not relative then
|
if not relative2 then
|
||||||
log('Normal', 'Transformed Move to Create for ', sync.config.name)
|
log('Normal', 'Transformed Move to Create for ', sync.config.name)
|
||||||
etyped = 'Create'
|
etyped = 'Create'
|
||||||
elseif not relative2 then
|
elseif not relative then
|
||||||
relative = relative2
|
relative = relative2
|
||||||
relative2 = nil
|
relative2 = nil
|
||||||
log('Normal', 'Transformed Move to Delete for ', sync.config.name)
|
log('Normal', 'Transformed Move to Delete for ', sync.config.name)
|
||||||
@ -2150,7 +2148,7 @@ local functionWriter = (function()
|
|||||||
--
|
--
|
||||||
local function splitStr(str)
|
local function splitStr(str)
|
||||||
local args = {}
|
local args = {}
|
||||||
while str ~= "" do
|
while str ~= '' do
|
||||||
-- break where argument stops
|
-- break where argument stops
|
||||||
local bp = #str
|
local bp = #str
|
||||||
-- in a quote
|
-- in a quote
|
||||||
@ -2217,7 +2215,7 @@ local functionWriter = (function()
|
|||||||
local first = true
|
local first = true
|
||||||
for _, v in ipairs(a) do
|
for _, v in ipairs(a) do
|
||||||
if not first then
|
if not first then
|
||||||
as = as.." .. "
|
as = as..' .. '
|
||||||
end
|
end
|
||||||
if v[1] then
|
if v[1] then
|
||||||
as = as..'"'..v[2]..'"'
|
as = as..'"'..v[2]..'"'
|
||||||
@ -2349,7 +2347,7 @@ local StatusFile = (function()
|
|||||||
if settings.statusInterval > 0 then
|
if settings.statusInterval > 0 then
|
||||||
-- already waiting
|
-- already waiting
|
||||||
if alarm and timestamp < alarm then
|
if alarm and timestamp < alarm then
|
||||||
log('Statusfile', "waiting(",timestamp," < ",alarm,")")
|
log('Statusfile', 'waiting(',timestamp,' < ',alarm,')')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- determines when a next write will be possible
|
-- determines when a next write will be possible
|
||||||
@ -2357,7 +2355,7 @@ local StatusFile = (function()
|
|||||||
local nextWrite =
|
local nextWrite =
|
||||||
lastWritten and timestamp + settings.statusInterval
|
lastWritten and timestamp + settings.statusInterval
|
||||||
if nextWrite and timestamp < nextWrite then
|
if nextWrite and timestamp < nextWrite then
|
||||||
log("Statusfile", "setting alarm: ", nextWrite)
|
log('Statusfile', 'setting alarm: ', nextWrite)
|
||||||
alarm = nextWrite
|
alarm = nextWrite
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -2366,17 +2364,16 @@ local StatusFile = (function()
|
|||||||
alarm = false
|
alarm = false
|
||||||
end
|
end
|
||||||
|
|
||||||
log("Statusfile", "writing now")
|
log('Statusfile', 'writing now')
|
||||||
local f, err = io.open(settings.statusFile, "w")
|
local f, err = io.open(settings.statusFile, 'w')
|
||||||
if not f then
|
if not f then
|
||||||
log("Error", "Cannot open status file '"..settings.statusFile..
|
log('Error', 'Cannot open status file "'..settings.statusFile.. '" :'..err)
|
||||||
"' :"..err)
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
f:write("Lsyncd status report at ", os.date(), "\n\n")
|
f:write('Lsyncd status report at ',os.date(),'\n\n')
|
||||||
for i, s in Syncs.iwalk() do
|
for i, s in Syncs.iwalk() do
|
||||||
s:statusReport(f)
|
s:statusReport(f)
|
||||||
f:write("\n")
|
f:write('\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
Inotify.statusReport(f)
|
Inotify.statusReport(f)
|
||||||
@ -2448,11 +2445,11 @@ end)()
|
|||||||
-----
|
-----
|
||||||
-- Current status of lsyncd.
|
-- Current status of lsyncd.
|
||||||
--
|
--
|
||||||
-- "init" ... on (re)init
|
-- 'init' ... on (re)init
|
||||||
-- "run" ... normal operation
|
-- 'run' ... normal operation
|
||||||
-- "fade" ... waits for remaining processes
|
-- 'fade' ... waits for remaining processes
|
||||||
--
|
--
|
||||||
local lsyncdStatus = "init"
|
local lsyncdStatus = 'init'
|
||||||
|
|
||||||
----
|
----
|
||||||
-- the cores interface to the runner
|
-- the cores interface to the runner
|
||||||
@ -2464,16 +2461,15 @@ local runner = {}
|
|||||||
-- Logs a backtrace
|
-- Logs a backtrace
|
||||||
--
|
--
|
||||||
function runner.callError(message)
|
function runner.callError(message)
|
||||||
log("Error", "IN LUA: ", message)
|
log('Error', 'IN LUA: ', message)
|
||||||
-- prints backtrace
|
-- prints backtrace
|
||||||
local level = 2
|
local level = 2
|
||||||
while true do
|
while true do
|
||||||
local info = debug.getinfo(level, "Sl")
|
local info = debug.getinfo(level, 'Sl')
|
||||||
if not info then
|
if not info then
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
log("Error", "Backtrace ", level - 1, " :",
|
log('Error', 'Backtrace ', level - 1, ' :', info.short_src, ":", info.currentline)
|
||||||
info.short_src, ":", info.currentline)
|
|
||||||
level = level + 1
|
level = level + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2508,16 +2504,16 @@ end
|
|||||||
function runner.cycle(timestamp)
|
function runner.cycle(timestamp)
|
||||||
-- goes through all syncs and spawns more actions
|
-- goes through all syncs and spawns more actions
|
||||||
-- if possible
|
-- if possible
|
||||||
if lsyncdStatus == "fade" then
|
if lsyncdStatus == 'fade' then
|
||||||
if processCount > 0 then
|
if processCount > 0 then
|
||||||
log("Normal", "waiting for ",processCount," more child processes.")
|
log('Normal', 'waiting for ',processCount,' more child processes.')
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if lsyncdStatus ~= "run" then
|
if lsyncdStatus ~= 'run' then
|
||||||
error("runner.cycle() called while not running!")
|
error('runner.cycle() called while not running!')
|
||||||
end
|
end
|
||||||
|
|
||||||
--- only let Syncs invoke actions if not on global limit
|
--- only let Syncs invoke actions if not on global limit
|
||||||
@ -2545,7 +2541,7 @@ function runner.cycle(timestamp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Called by core before anything is "-help" or "--help" is in
|
-- Called by core before anything is '-help' or '--help' is in
|
||||||
-- the arguments.
|
-- the arguments.
|
||||||
--
|
--
|
||||||
function runner.help()
|
function runner.help()
|
||||||
@ -2632,11 +2628,11 @@ function runner.configure(args, monitors)
|
|||||||
monitor =
|
monitor =
|
||||||
{-1, function(monitor)
|
{-1, function(monitor)
|
||||||
if not monitor then
|
if not monitor then
|
||||||
io.stdout:write("This Lsyncd supports these monitors:\n")
|
io.stdout:write('This Lsyncd supports these monitors:\n')
|
||||||
for _, v in ipairs(Monitors.list) do
|
for _, v in ipairs(Monitors.list) do
|
||||||
io.stdout:write(" ",v,"\n")
|
io.stdout:write(' ',v,'\n')
|
||||||
end
|
end
|
||||||
io.stdout:write("\n");
|
io.stdout:write('\n');
|
||||||
lsyncd.terminate(-1); -- ERRNO
|
lsyncd.terminate(-1); -- ERRNO
|
||||||
else
|
else
|
||||||
clSettings.monitor=monitor
|
clSettings.monitor=monitor
|
||||||
@ -2653,21 +2649,21 @@ function runner.configure(args, monitors)
|
|||||||
rsync =
|
rsync =
|
||||||
{2, function(src, trg)
|
{2, function(src, trg)
|
||||||
clSettings.syncs = clSettings.syncs or {}
|
clSettings.syncs = clSettings.syncs or {}
|
||||||
table.insert(clSettings.syncs, {"rsync", src, trg})
|
table.insert(clSettings.syncs, {'rsync', src, trg})
|
||||||
end},
|
end},
|
||||||
rsyncssh =
|
rsyncssh =
|
||||||
{3, function(src, host, tdir)
|
{3, function(src, host, tdir)
|
||||||
clSettings.syncs = clSettings.syncs or {}
|
clSettings.syncs = clSettings.syncs or {}
|
||||||
table.insert(clSettings.syncs, {"rsyncssh", src, host, tdir})
|
table.insert(clSettings.syncs, {'rsyncssh', src, host, tdir})
|
||||||
end},
|
end},
|
||||||
direct =
|
direct =
|
||||||
{2, function(src, trg)
|
{2, function(src, trg)
|
||||||
clSettings.syncs = clSettings.syncs or {}
|
clSettings.syncs = clSettings.syncs or {}
|
||||||
table.insert(clSettings.syncs, {"direct", src, trg})
|
table.insert(clSettings.syncs, {'direct', src, trg})
|
||||||
end},
|
end},
|
||||||
version =
|
version =
|
||||||
{0, function()
|
{0, function()
|
||||||
io.stdout:write("Version: ", lsyncd_version,"\n")
|
io.stdout:write('Version: ',lsyncd_version,'\n')
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end}
|
end}
|
||||||
}
|
}
|
||||||
@ -2676,21 +2672,21 @@ function runner.configure(args, monitors)
|
|||||||
local i = 1
|
local i = 1
|
||||||
while i <= #args do
|
while i <= #args do
|
||||||
local a = args[i]
|
local a = args[i]
|
||||||
if a:sub(1, 1) ~= "-" then
|
if a:sub(1, 1) ~= '-' then
|
||||||
table.insert(nonopts, args[i])
|
table.insert(nonopts, args[i])
|
||||||
else
|
else
|
||||||
if a:sub(1, 2) == "--" then
|
if a:sub(1, 2) == '--' then
|
||||||
a = a:sub(3)
|
a = a:sub(3)
|
||||||
else
|
else
|
||||||
a = a:sub(2)
|
a = a:sub(2)
|
||||||
end
|
end
|
||||||
local o = options[a]
|
local o = options[a]
|
||||||
if not o then
|
if not o then
|
||||||
log("Error","unknown option command line option ", args[i])
|
log('Error','unknown option command line option ', args[i])
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
if o[1] >= 0 and i + o[1] > #args then
|
if o[1] >= 0 and i + o[1] > #args then
|
||||||
log("Error",a," needs ",o[1]," arguments")
|
log('Error',a,' needs ',o[1],' arguments')
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
elseif o[1] < 0 then
|
elseif o[1] < 0 then
|
||||||
o[1] = -o[1]
|
o[1] = -o[1]
|
||||||
@ -2713,8 +2709,7 @@ function runner.configure(args, monitors)
|
|||||||
|
|
||||||
if clSettings.syncs then
|
if clSettings.syncs then
|
||||||
if #nonopts ~= 0 then
|
if #nonopts ~= 0 then
|
||||||
log("Error",
|
log('Error', 'There cannot be command line default syncs with a config file.')
|
||||||
"There cannot be command line default syncs with a config file.")
|
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -2723,7 +2718,7 @@ function runner.configure(args, monitors)
|
|||||||
elseif #nonopts == 1 then
|
elseif #nonopts == 1 then
|
||||||
return nonopts[1]
|
return nonopts[1]
|
||||||
else
|
else
|
||||||
log("Error", "There can only be one config file in command line.")
|
log('Error', 'There can only be one config file in command line.')
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2743,10 +2738,10 @@ function runner.initialize(firstTime)
|
|||||||
-- From this point on, no globals may be created anymore
|
-- From this point on, no globals may be created anymore
|
||||||
lockGlobals()
|
lockGlobals()
|
||||||
|
|
||||||
-- copies simple settings with numeric keys to "key=true" settings.
|
-- copies simple settings with numeric keys to 'key=true' settings.
|
||||||
for k, v in ipairs(settings) do
|
for k, v in ipairs(settings) do
|
||||||
if settings[v] then
|
if settings[v] then
|
||||||
log("Error", "Double setting '"..v.."'")
|
log('Error', 'Double setting "'..v..'"')
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
settings[v]=true
|
settings[v]=true
|
||||||
@ -2754,7 +2749,7 @@ function runner.initialize(firstTime)
|
|||||||
|
|
||||||
-- all command line settings overwrite config file settings
|
-- all command line settings overwrite config file settings
|
||||||
for k, v in pairs(clSettings) do
|
for k, v in pairs(clSettings) do
|
||||||
if k ~= "syncs" then
|
if k ~= 'syncs' then
|
||||||
settings[k]=v
|
settings[k]=v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2767,37 +2762,30 @@ function runner.initialize(firstTime)
|
|||||||
-- adds syncs specified by command line.
|
-- adds syncs specified by command line.
|
||||||
if clSettings.syncs then
|
if clSettings.syncs then
|
||||||
for _, s in ipairs(clSettings.syncs) do
|
for _, s in ipairs(clSettings.syncs) do
|
||||||
if s[1] == "rsync" then
|
if s[1] == 'rsync' then
|
||||||
sync{default.rsync, source=s[2], target=s[3]}
|
sync{default.rsync, source=s[2], target=s[3]}
|
||||||
elseif s[1] == "rsyncssh" then
|
elseif s[1] == 'rsyncssh' then
|
||||||
sync{default.rsyncssh, source=s[2], host=s[3], targetdir=s[4]}
|
sync{default.rsyncssh, source=s[2], host=s[3], targetdir=s[4]}
|
||||||
elseif s[1] == "direct" then
|
elseif s[1] == 'direct' then
|
||||||
sync{default.direct, source=s[2], target=s[3]}
|
sync{default.direct, source=s[2], target=s[3]}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if settings.nodaemon then
|
if settings.nodaemon then
|
||||||
lsyncd.configure("nodaemon")
|
lsyncd.configure('nodaemon')
|
||||||
end
|
end
|
||||||
if settings.logfile then
|
if settings.logfile then
|
||||||
lsyncd.configure("logfile", settings.logfile)
|
lsyncd.configure('logfile', settings.logfile)
|
||||||
end
|
end
|
||||||
if settings.logident then
|
if settings.logident then
|
||||||
lsyncd.configure("logident", settings.logident)
|
lsyncd.configure('logident', settings.logident)
|
||||||
end
|
end
|
||||||
if settings.logfacility then
|
if settings.logfacility then
|
||||||
lsyncd.configure("logfacility", settings.logfacility)
|
lsyncd.configure('logfacility', settings.logfacility)
|
||||||
end
|
end
|
||||||
if settings.pidfile then
|
if settings.pidfile then
|
||||||
lsyncd.configure("pidfile", settings.pidfile)
|
lsyncd.configure('pidfile', settings.pidfile)
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: Remove after deprecation timespan.
|
|
||||||
if settings.statusIntervall ~= nil and settings.statusInterval == nil then
|
|
||||||
log("Warn",
|
|
||||||
"The setting 'statusIntervall' has been renamed to 'statusInterval'.")
|
|
||||||
settings.statusInterval = settings.statusIntervall
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -2808,18 +2796,17 @@ function runner.initialize(firstTime)
|
|||||||
|
|
||||||
-- makes sure the user gave Lsyncd anything to do
|
-- makes sure the user gave Lsyncd anything to do
|
||||||
if Syncs.size() == 0 then
|
if Syncs.size() == 0 then
|
||||||
log("Error", "Nothing to watch!")
|
log('Error', 'Nothing to watch!')
|
||||||
log("Error", "Use sync(SOURCE, TARGET, BEHAVIOR) in your config file.");
|
|
||||||
os.exit(-1) -- ERRNO
|
os.exit(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
|
|
||||||
-- from now on use logging as configured instead of stdout/err.
|
-- from now on use logging as configured instead of stdout/err.
|
||||||
lsyncdStatus = "run";
|
lsyncdStatus = 'run';
|
||||||
lsyncd.configure("running");
|
lsyncd.configure('running');
|
||||||
|
|
||||||
local ufuncs = {
|
local ufuncs = {
|
||||||
"onAttrib", "onCreate", "onDelete",
|
'onAttrib', 'onCreate', 'onDelete',
|
||||||
"onModify", "onMove", "onStartup"
|
'onModify', 'onMove', 'onStartup',
|
||||||
}
|
}
|
||||||
|
|
||||||
-- translates layer 3 scripts
|
-- translates layer 3 scripts
|
||||||
@ -2836,13 +2823,12 @@ function runner.initialize(firstTime)
|
|||||||
|
|
||||||
-- runs through the Syncs created by users
|
-- runs through the Syncs created by users
|
||||||
for _, s in Syncs.iwalk() do
|
for _, s in Syncs.iwalk() do
|
||||||
if s.config.monitor == "inotify" then
|
if s.config.monitor == 'inotify' then
|
||||||
Inotify.addSync(s, s.source)
|
Inotify.addSync(s, s.source)
|
||||||
elseif s.config.monitor == "fsevents" then
|
elseif s.config.monitor == 'fsevents' then
|
||||||
Fsevents.addSync(s, s.source)
|
Fsevents.addSync(s, s.source)
|
||||||
else
|
else
|
||||||
error("sync "..s.config.name..
|
error('sync '..s.config.name..' has no known event monitor interface.')
|
||||||
" has no known event monitor interface.")
|
|
||||||
end
|
end
|
||||||
-- if the sync has an init function, stacks an init delay
|
-- if the sync has an init function, stacks an init delay
|
||||||
-- that will cause the init function to be called.
|
-- that will cause the init function to be called.
|
||||||
@ -2860,7 +2846,7 @@ end
|
|||||||
-- times ... the alarm time (only read if number is 1)
|
-- times ... the alarm time (only read if number is 1)
|
||||||
--
|
--
|
||||||
function runner.getAlarm()
|
function runner.getAlarm()
|
||||||
if lsyncdStatus ~= "run" then
|
if lsyncdStatus ~= 'run' then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local alarm = false
|
local alarm = false
|
||||||
@ -2869,7 +2855,7 @@ function runner.getAlarm()
|
|||||||
--
|
--
|
||||||
local function checkAlarm(a)
|
local function checkAlarm(a)
|
||||||
if a == nil then
|
if a == nil then
|
||||||
error("got nil alarm")
|
error('got nil alarm')
|
||||||
end
|
end
|
||||||
if alarm == true or not a then
|
if alarm == true or not a then
|
||||||
-- already immediate or no new alarm
|
-- already immediate or no new alarm
|
||||||
@ -2888,7 +2874,7 @@ function runner.getAlarm()
|
|||||||
checkAlarm(s:getAlarm())
|
checkAlarm(s:getAlarm())
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log("Alarm", "at global process limit.")
|
log('Alarm', 'at global process limit.')
|
||||||
end
|
end
|
||||||
|
|
||||||
-- checks if a statusfile write has been delayed
|
-- checks if a statusfile write has been delayed
|
||||||
@ -2896,7 +2882,7 @@ function runner.getAlarm()
|
|||||||
-- checks for an userAlarm
|
-- checks for an userAlarm
|
||||||
checkAlarm(UserAlarms.getAlarm())
|
checkAlarm(UserAlarms.getAlarm())
|
||||||
|
|
||||||
log("Alarm","runner.getAlarm returns: ",alarm)
|
log('Alarm', 'runner.getAlarm returns: ',alarm)
|
||||||
return alarm
|
return alarm
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2919,7 +2905,7 @@ runner.fsEventsEvent = Fsevents.event
|
|||||||
--
|
--
|
||||||
function runner.collector(pid, exitcode)
|
function runner.collector(pid, exitcode)
|
||||||
if exitcode ~= 0 then
|
if exitcode ~= 0 then
|
||||||
log("Error", "Startup process", pid, " failed")
|
log('Error', 'Startup process',pid,' failed')
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
@ -2929,24 +2915,24 @@ end
|
|||||||
-- Called by core when an overflow happened.
|
-- Called by core when an overflow happened.
|
||||||
--
|
--
|
||||||
function runner.overflow()
|
function runner.overflow()
|
||||||
log("Normal", "--- OVERFLOW on inotify event queue ---")
|
log('Normal', '--- OVERFLOW in event queue ---')
|
||||||
lsyncdStatus = "fade"
|
lsyncdStatus = 'fade'
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Called by core on a hup signal.
|
-- Called by core on a hup signal.
|
||||||
--
|
--
|
||||||
function runner.hup()
|
function runner.hup()
|
||||||
log("Normal", "--- HUP signal, resetting ---")
|
log('Normal', '--- HUP signal, resetting ---')
|
||||||
lsyncdStatus = "fade"
|
lsyncdStatus = 'fade'
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Called by core on a term signal.
|
-- Called by core on a term signal.
|
||||||
--
|
--
|
||||||
function runner.term()
|
function runner.term()
|
||||||
log("Normal", "--- TERM signal, fading ---")
|
log('Normal', '--- TERM signal, fading ---')
|
||||||
lsyncdStatus = "fade"
|
lsyncdStatus = 'fade'
|
||||||
end
|
end
|
||||||
|
|
||||||
--============================================================================
|
--============================================================================
|
||||||
@ -2958,8 +2944,8 @@ end
|
|||||||
-- @returns an Inlet to that sync.
|
-- @returns an Inlet to that sync.
|
||||||
--
|
--
|
||||||
function sync(opts)
|
function sync(opts)
|
||||||
if lsyncdStatus ~= "init" then
|
if lsyncdStatus ~= 'init' then
|
||||||
error("Sync can only be created on initialization.", 2)
|
error('Sync can only be created during initialization.', 2)
|
||||||
end
|
end
|
||||||
return Syncs.add(opts).inlet
|
return Syncs.add(opts).inlet
|
||||||
end
|
end
|
||||||
@ -2975,29 +2961,30 @@ end
|
|||||||
-- @param ... arguments
|
-- @param ... arguments
|
||||||
--
|
--
|
||||||
function spawn(agent, binary, ...)
|
function spawn(agent, binary, ...)
|
||||||
if agent == nil or type(agent) ~= "table" then
|
if agent == nil or type(agent) ~= 'table' then
|
||||||
error("spawning with an invalid agent", 2)
|
error('spawning with an invalid agent', 2)
|
||||||
end
|
end
|
||||||
if lsyncdStatus == "fade" then
|
if lsyncdStatus == 'fade' then
|
||||||
log("Normal", "ignored spawn processs since status fading")
|
log('Normal', 'ignored process spawning while fading')
|
||||||
|
return
|
||||||
end
|
end
|
||||||
if type(binary) ~= "string" then
|
if type(binary) ~= 'string' then
|
||||||
error("calling spawn(agent, binary, ...), binary is not a string", 2)
|
error('calling spawn(agent, binary, ...), binary is not a string', 2)
|
||||||
end
|
end
|
||||||
local dol = InletFactory.getDelayOrList(agent)
|
local dol = InletFactory.getDelayOrList(agent)
|
||||||
if not dol then
|
if not dol then
|
||||||
error("spawning with an unknown agent", 2)
|
error('spawning with an unknown agent', 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- checks if spawn is called on already active event
|
-- checks if spawn is called on already active event
|
||||||
if dol.status then
|
if dol.status then
|
||||||
if dol.status ~= "wait" then
|
if dol.status ~= "wait" then
|
||||||
error("Spawn() called on an non-waiting event", 2)
|
error('spawn() called on an non-waiting event', 2)
|
||||||
end
|
end
|
||||||
else -- is a list
|
else -- is a list
|
||||||
for _, d in ipairs(dol) do
|
for _, d in ipairs(dol) do
|
||||||
if d.status ~= "wait" and d.status ~= "block" then
|
if d.status ~= 'wait' and d.status ~= 'block' then
|
||||||
error("Spawn() called on an non-waiting event list", 2)
|
error('spawn() called on an non-waiting event list', 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3007,18 +2994,18 @@ function spawn(agent, binary, ...)
|
|||||||
if pid and pid > 0 then
|
if pid and pid > 0 then
|
||||||
processCount = processCount + 1
|
processCount = processCount + 1
|
||||||
if settings.maxProcesses and processCount > settings.maxProcesses then
|
if settings.maxProcesses and processCount > settings.maxProcesses then
|
||||||
error("Spawned too much processes!")
|
error('Spawned too much processes!')
|
||||||
end
|
end
|
||||||
local sync = InletFactory.getSync(agent)
|
local sync = InletFactory.getSync(agent)
|
||||||
-- delay or list
|
-- delay or list
|
||||||
if dol.status then
|
if dol.status then
|
||||||
-- is a delay
|
-- is a delay
|
||||||
dol.status = "active"
|
dol.status = 'active'
|
||||||
sync.processes[pid] = dol
|
sync.processes[pid] = dol
|
||||||
else
|
else
|
||||||
-- is a list
|
-- is a list
|
||||||
for _, d in ipairs(dol) do
|
for _, d in ipairs(dol) do
|
||||||
d.status = "active"
|
d.status = 'active'
|
||||||
end
|
end
|
||||||
sync.processes[pid] = dol
|
sync.processes[pid] = dol
|
||||||
end
|
end
|
||||||
@ -3029,7 +3016,7 @@ end
|
|||||||
-- Spawns a child process using the default shell.
|
-- Spawns a child process using the default shell.
|
||||||
--
|
--
|
||||||
function spawnShell(agent, command, ...)
|
function spawnShell(agent, command, ...)
|
||||||
return spawn(agent, "/bin/sh", "-c", command, "/bin/sh", ...)
|
return spawn(agent, '/bin/sh', '-c', command, '/bin/sh', ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -3078,34 +3065,34 @@ end
|
|||||||
-- Exitcodes to retry on network failures of rsync.
|
-- Exitcodes to retry on network failures of rsync.
|
||||||
--
|
--
|
||||||
local rsync_exitcodes = {
|
local rsync_exitcodes = {
|
||||||
[ 0] = "ok",
|
[ 0] = 'ok',
|
||||||
[ 1] = "die",
|
[ 1] = 'die',
|
||||||
[ 2] = "die",
|
[ 2] = 'die',
|
||||||
[ 3] = "again",
|
[ 3] = 'again',
|
||||||
[ 4] = "die",
|
[ 4] = 'die',
|
||||||
[ 5] = "again",
|
[ 5] = 'again',
|
||||||
[ 6] = "again",
|
[ 6] = 'again',
|
||||||
[ 10] = "again",
|
[ 10] = 'again',
|
||||||
[ 11] = "again",
|
[ 11] = 'again',
|
||||||
[ 12] = "again",
|
[ 12] = 'again',
|
||||||
[ 14] = "again",
|
[ 14] = 'again',
|
||||||
[ 20] = "again",
|
[ 20] = 'again',
|
||||||
[ 21] = "again",
|
[ 21] = 'again',
|
||||||
[ 22] = "again",
|
[ 22] = 'again',
|
||||||
[ 23] = "ok", -- partial transfers are ok, since Lsyncd has registered the event that
|
[ 23] = 'ok', -- partial transfers are ok, since Lsyncd has registered the event that
|
||||||
[ 24] = "ok", -- caused the transfer to be partial and will recall rsync.
|
[ 24] = 'ok', -- caused the transfer to be partial and will recall rsync.
|
||||||
[ 25] = "die",
|
[ 25] = 'die',
|
||||||
[ 30] = "again",
|
[ 30] = 'again',
|
||||||
[ 35] = "again",
|
[ 35] = 'again',
|
||||||
[255] = "again",
|
[255] = 'again',
|
||||||
}
|
}
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Exitcodes to retry on network failures of rsync.
|
-- Exitcodes to retry on network failures of rsync.
|
||||||
--
|
--
|
||||||
local ssh_exitcodes = {
|
local ssh_exitcodes = {
|
||||||
[0] = "ok",
|
[0] = 'ok',
|
||||||
[255] = "again",
|
[255] = 'again',
|
||||||
}
|
}
|
||||||
|
|
||||||
-----
|
-----
|
||||||
@ -3119,7 +3106,7 @@ local default_rsync = {
|
|||||||
-- gets all events ready for syncing
|
-- gets all events ready for syncing
|
||||||
local elist = inlet.getEvents(
|
local elist = inlet.getEvents(
|
||||||
function(event)
|
function(event)
|
||||||
return event.etype ~= "Init" and event.etype ~= "Blanket"
|
return event.etype ~= 'Init' and event.etype ~= 'Blanket'
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -3130,16 +3117,16 @@ local default_rsync = {
|
|||||||
if not p then
|
if not p then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return p:gsub("%?", "\\?"):
|
return p:gsub('%?', '\\?'):
|
||||||
gsub("%*", "\\*"):
|
gsub('%*', '\\*'):
|
||||||
gsub("%[", "\\["):
|
gsub('%[', '\\['):
|
||||||
gsub("%]", "\\]")
|
gsub('%]', '\\]')
|
||||||
end
|
end
|
||||||
|
|
||||||
local paths = elist.getPaths(
|
local paths = elist.getPaths(
|
||||||
function(etype, path1, path2)
|
function(etype, path1, path2)
|
||||||
if etype == "Delete" and string.byte(path1, -1) == 47 then
|
if etype == 'Delete' and string.byte(path1, -1) == 47 then
|
||||||
return sub(path1) .. "***", sub(path2)
|
return sub(path1)..'***', sub(path2)
|
||||||
else
|
else
|
||||||
return sub(path1), sub(path2)
|
return sub(path1), sub(path2)
|
||||||
end
|
end
|
||||||
@ -3165,33 +3152,31 @@ local default_rsync = {
|
|||||||
-- adds a path to the filter, for rsync this needs
|
-- adds a path to the filter, for rsync this needs
|
||||||
-- to have entries for all steps in the path, so the file
|
-- to have entries for all steps in the path, so the file
|
||||||
-- d1/d2/d3/f1 needs filters
|
-- d1/d2/d3/f1 needs 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 do
|
||||||
addToFilter(pp)
|
addToFilter(pp)
|
||||||
pp = string.match(pp, "^(.*/)[^/]+/?")
|
pp = string.match(pp, '^(.*/)[^/]+/?')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local filterS = table.concat(filterI, "\n")
|
local filterS = table.concat(filterI, '\n')
|
||||||
local filter0 = table.concat(filterI, "\000")
|
local filter0 = table.concat(filterI, '\000')
|
||||||
log("Normal",
|
log('Normal', 'Calling rsync with filter-list of new/modified files/dirs\n', filterS)
|
||||||
"Calling rsync with filter-list of new/modified files/dirs\n",
|
|
||||||
filterS)
|
|
||||||
local config = inlet.getConfig()
|
local config = inlet.getConfig()
|
||||||
spawn(elist, config.rsyncBinary,
|
spawn(elist, config.rsyncBinary,
|
||||||
"<", filter0,
|
'<', filter0,
|
||||||
config.rsyncOpts,
|
config.rsyncOpts,
|
||||||
"-r",
|
'-r',
|
||||||
"--delete",
|
'--delete',
|
||||||
"--force",
|
'--force',
|
||||||
"--from0",
|
'--from0',
|
||||||
"--include-from=-",
|
'--include-from=-',
|
||||||
"--exclude=*",
|
'--exclude=*',
|
||||||
config.source,
|
config.source,
|
||||||
config.target)
|
config.target)
|
||||||
end,
|
end,
|
||||||
@ -3204,22 +3189,22 @@ local default_rsync = {
|
|||||||
local inlet = event.inlet;
|
local inlet = event.inlet;
|
||||||
local excludes = inlet.getExcludes();
|
local excludes = inlet.getExcludes();
|
||||||
if #excludes == 0 then
|
if #excludes == 0 then
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
log('Normal', 'recursive startup rsync: ', config.source, ' -> ', config.target)
|
||||||
" -> ", config.target)
|
|
||||||
spawn(event, config.rsyncBinary,
|
spawn(event, config.rsyncBinary,
|
||||||
"--delete",
|
'--delete',
|
||||||
config.rsyncOpts, "-r",
|
config.rsyncOpts,
|
||||||
|
'-r',
|
||||||
config.source,
|
config.source,
|
||||||
config.target)
|
config.target)
|
||||||
else
|
else
|
||||||
local exS = table.concat(excludes, "\n")
|
local exS = table.concat(excludes, "\n")
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
log('Normal', 'recursive startup rsync: ',config.source,
|
||||||
" -> ", config.target," excluding\n", exS)
|
' -> ',config.target,' excluding\n',exS)
|
||||||
spawn(event, config.rsyncBinary,
|
spawn(event, config.rsyncBinary,
|
||||||
"<", exS,
|
'<', exS,
|
||||||
"--exclude-from=-",
|
'--exclude-from=-',
|
||||||
"--delete",
|
'--delete',
|
||||||
config.rsyncOpts, "-r",
|
config.rsyncOpts, '-r',
|
||||||
config.source,
|
config.source,
|
||||||
config.target)
|
config.target)
|
||||||
end
|
end
|
||||||
@ -3230,31 +3215,24 @@ local default_rsync = {
|
|||||||
--
|
--
|
||||||
prepare = function(config)
|
prepare = function(config)
|
||||||
if not config.target then
|
if not config.target then
|
||||||
error("default.rsync needs 'target' configured", 4)
|
error('default.rsync needs "target" configured', 4)
|
||||||
end
|
|
||||||
|
|
||||||
if config.rsyncOps then
|
|
||||||
if config.rsyncOpts ~= "-lts" then
|
|
||||||
error("'rsyncOpts' and 'rsyncOps' provided in config, decide for one.")
|
|
||||||
end
|
|
||||||
config.rsyncOpts = config.rsyncOps
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- appends a / to target if not present
|
-- appends a / to target if not present
|
||||||
if string.sub(config.target, -1) ~= "/" then
|
if string.sub(config.target, -1) ~= '/' then
|
||||||
config.target = config.target .. "/"
|
config.target = config.target..'/'
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- The rsync binary called.
|
-- The rsync binary called.
|
||||||
--
|
--
|
||||||
rsyncBinary = "/usr/bin/rsync",
|
rsyncBinary = '/usr/bin/rsync',
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Calls rsync with this default short opts.
|
-- Calls rsync with this default short opts.
|
||||||
--
|
--
|
||||||
rsyncOpts = "-lts",
|
rsyncOpts = '-lts',
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- exit codes for rsync.
|
-- exit codes for rsync.
|
||||||
@ -3282,12 +3260,13 @@ local default_rsyncssh = {
|
|||||||
-- makes move local on host
|
-- makes move local on host
|
||||||
-- if fails deletes the source...
|
-- if fails deletes the source...
|
||||||
if event.etype == 'Move' then
|
if event.etype == 'Move' then
|
||||||
log("Normal", "Moving ",event.path," -> ",event2.path)
|
log('Normal', 'Moving ',event.path,' -> ',event2.path)
|
||||||
spawn(event, "/usr/bin/ssh",
|
spawn(event, '/usr/bin/ssh',
|
||||||
config.host, "mv",
|
config.host,
|
||||||
|
'mv',
|
||||||
'\"' .. config.targetdir .. event.path .. '\"',
|
'\"' .. config.targetdir .. event.path .. '\"',
|
||||||
'\"' .. config.targetdir .. event2.path .. '\"',
|
'\"' .. config.targetdir .. event2.path .. '\"',
|
||||||
"||", "rm", "-rf",
|
'||', 'rm', '-rf',
|
||||||
'\"' .. config.targetdir .. event.path .. '\"')
|
'\"' .. config.targetdir .. event.path .. '\"')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -3297,7 +3276,7 @@ local default_rsyncssh = {
|
|||||||
if event.etype == 'Delete' then
|
if event.etype == 'Delete' then
|
||||||
local elist = inlet.getEvents(
|
local elist = inlet.getEvents(
|
||||||
function(e)
|
function(e)
|
||||||
return e.etype == "Delete"
|
return e.etype == 'Delete'
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local paths = elist.getPaths(
|
local paths = elist.getPaths(
|
||||||
@ -3310,17 +3289,17 @@ local default_rsyncssh = {
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
for _, v in pairs(paths) do
|
for _, v in pairs(paths) do
|
||||||
if string.match(v, "^%s*/+%s*$") then
|
if string.match(v, '^%s*/+%s*$') then
|
||||||
log("Error", "refusing to `rm -rf /` the target!")
|
log('Error', 'refusing to `rm -rf /` the target!')
|
||||||
terminate(-1) -- ERRNO
|
terminate(-1) -- ERRNO
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sPaths = table.concat(paths, "\n")
|
local sPaths = table.concat(paths, "\n")
|
||||||
local zPaths = table.concat(paths, config.xargs.delimiter)
|
local zPaths = table.concat(paths, config.xargs.delimiter)
|
||||||
log("Normal", "Deleting list\n", sPaths)
|
log('Normal', 'Deleting list\n', sPaths)
|
||||||
spawn(elist, "/usr/bin/ssh",
|
spawn(elist, '/usr/bin/ssh',
|
||||||
"<", zPaths,
|
'<', zPaths,
|
||||||
config.host,
|
config.host,
|
||||||
config.xargs.binary, config.xargs.xparams)
|
config.xargs.binary, config.xargs.xparams)
|
||||||
return
|
return
|
||||||
@ -3329,10 +3308,11 @@ local default_rsyncssh = {
|
|||||||
-- for everything else spawn a rsync
|
-- for everything else spawn a rsync
|
||||||
local elist = inlet.getEvents(
|
local elist = inlet.getEvents(
|
||||||
function(e)
|
function(e)
|
||||||
return e.etype ~= "Move" and
|
-- TODO use a table
|
||||||
e.etype ~= "Delete" and
|
return e.etype ~= 'Move' and
|
||||||
e.etype ~= "Init" and
|
e.etype ~= 'Delete' and
|
||||||
e.etype ~= "Blanket"
|
e.etype ~= 'Init' and
|
||||||
|
e.etype ~= 'Blanket'
|
||||||
end)
|
end)
|
||||||
local paths = elist.getPaths()
|
local paths = elist.getPaths()
|
||||||
|
|
||||||
@ -3344,15 +3324,15 @@ local default_rsyncssh = {
|
|||||||
end
|
end
|
||||||
local sPaths = table.concat(paths, "\n")
|
local sPaths = table.concat(paths, "\n")
|
||||||
local zPaths = table.concat(paths, "\000")
|
local zPaths = table.concat(paths, "\000")
|
||||||
log("Normal", "Rsyncing list\n", sPaths)
|
log('Normal', 'Rsyncing list\n', sPaths)
|
||||||
spawn(
|
spawn(
|
||||||
elist, config.rsyncBinary,
|
elist, config.rsyncBinary,
|
||||||
"<", zPaths,
|
'<', zPaths,
|
||||||
config.rsyncOpts,
|
config.rsyncOpts,
|
||||||
"--from0",
|
'--from0',
|
||||||
"--files-from=-",
|
'--files-from=-',
|
||||||
config.source,
|
config.source,
|
||||||
config.host .. ":" .. config.targetdir
|
config.host .. ':' .. config.targetdir
|
||||||
)
|
)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -3360,9 +3340,9 @@ local default_rsyncssh = {
|
|||||||
-- Called when collecting a finished child process
|
-- Called when collecting a finished child process
|
||||||
--
|
--
|
||||||
collect = function(agent, exitcode)
|
collect = function(agent, exitcode)
|
||||||
if not agent.isList and agent.etype == "Init" then
|
if not agent.isList and agent.etype == 'Init' then
|
||||||
local rc = rsync_exitcodes[exitcode]
|
local rc = rsync_exitcodes[exitcode]
|
||||||
if rc == "ok" then
|
if rc == 'ok' then
|
||||||
log("Normal", "Startup of '",agent.source,"' finished.")
|
log("Normal", "Startup of '",agent.source,"' finished.")
|
||||||
elseif rc == "again" then
|
elseif rc == "again" then
|
||||||
if settings.insist then
|
if settings.insist then
|
||||||
@ -3606,7 +3586,7 @@ local default_direct = {
|
|||||||
--
|
--
|
||||||
prepare = function(config)
|
prepare = function(config)
|
||||||
if not config.target then
|
if not config.target then
|
||||||
error("default.direct needs 'target' configured", 4)
|
error('default.direct needs "target".', 4)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -3623,12 +3603,12 @@ local default_direct = {
|
|||||||
-----
|
-----
|
||||||
-- The rsync binary called.
|
-- The rsync binary called.
|
||||||
--
|
--
|
||||||
rsyncBinary = "/usr/bin/rsync",
|
rsyncBinary = '/usr/bin/rsync',
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- For startup sync
|
-- For startup sync
|
||||||
--
|
--
|
||||||
rsyncOpts = "-lts",
|
rsyncOpts = '-lts',
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- On many system multiple disk operations just rather slow down
|
-- On many system multiple disk operations just rather slow down
|
||||||
@ -3653,13 +3633,13 @@ default = {
|
|||||||
-- in case of moves getEvent returns the origin and dest of the move
|
-- in case of moves getEvent returns the origin and dest of the move
|
||||||
local event, event2 = inlet.getEvent()
|
local event, event2 = inlet.getEvent()
|
||||||
local config = inlet.getConfig()
|
local config = inlet.getConfig()
|
||||||
local func = config["on".. event.etype]
|
local func = config['on'.. event.etype]
|
||||||
if func then
|
if func then
|
||||||
func(event, event2)
|
func(event, event2)
|
||||||
end
|
end
|
||||||
-- if function didnt change the wait status its not interested
|
-- if function didnt change the wait status its not interested
|
||||||
-- in this event -> drop it.
|
-- in this event -> drop it.
|
||||||
if event.status == "wait" then
|
if event.status == 'wait' then
|
||||||
inlet.discardEvent(event)
|
inlet.discardEvent(event)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user