From ffb2ee7909ae8c37f5e85b347ec4d387bf9ca7b9 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Sat, 13 Nov 2010 20:31:24 +0000 Subject: [PATCH] --- examples/lrsync.lua | 2 +- lsyncd.lua | 33 ++++++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/examples/lrsync.lua b/examples/lrsync.lua index 28c9de8..ffa9d9b 100644 --- a/examples/lrsync.lua +++ b/examples/lrsync.lua @@ -8,5 +8,5 @@ settings = { statusIntervall = 1, } -sync{default.rsync, source="src", target="dst/", excludeFrom="exclude"} +sync{default.rsync, source="src", target="mooooooooooooooooooooo.com:dst/", excludeFrom="exclude"} diff --git a/lsyncd.lua b/lsyncd.lua index cc65c2f..7a83aed 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -273,7 +273,7 @@ local Inlet, InletControl = (function() -- TODO give user a readonly version. -- config = function(event) - return e2d[event].sync.config + return sync.config end, inlet = function(event) @@ -869,6 +869,12 @@ local Sync = (function() else -- sets the delay on wait again delay.status = "wait" + local alarm = self.config.delay + -- delays at least 1 second + if alarm < 1 then + alarm = 1 + end + delay.alarm = lsyncd.addtoclock(lsyncd.now(), alarm) end else log("Delay", "collected a list") @@ -878,6 +884,23 @@ local Sync = (function() log("Error", "Critical exitcode."); terminate(-1) --ERRNO end + if rc == "again" then + -- sets the delay on wait again + delay.status = "wait" + local alarm = self.config.delay + -- delays at least 1 second + if alarm < 1 then + alarm = 1 + end + alarm = lsyncd.addtoclock(lsyncd.now(), alarm) + for k, d in pairs(delay) do + if type(k) == "number" then + d.alarm = alarm + d.status = "wait" + end + end + + end for k, d in pairs(delay) do if type(k) == "number" then if rc ~= "again" then @@ -2303,12 +2326,12 @@ local default_rssh = { -- Called when collecting a finished child process -- collect = function(agent, exitcode) - if agent.etype == "Blanket" then + if not agent.isList and agent.etype == "Blanket" then if exitcode == 0 then log("Normal", "Startup of '",agent.source,"' finished.") elseif rsync_exitcodes[exitcode] == "again" then log("Normal", - "Retring startup of '",agent.source,"' finished.") + "Retrying startup of '",agent.source,"'.") return "again" else log("Error", "Failure on startup of '",agent.source,"'.") @@ -2462,14 +2485,14 @@ default = { collect = function(agent, exitcode) local config = agent.config - if agent.etype == "Blanket" then + if not agent.isList and agent.etype == "Blanket" then if exitcode == 0 then log("Normal", "Startup of '",agent.source,"' finished.") elseif config.exitcodes and config.exitcodes[exitcode] == "again" then log("Normal", - "Retring startup of '",agent.source,"' finished.") + "Retrying startup of '",agent.source,"'.") return "again" else log("Error", "Failure on startup of '",agent.source,"'.")