This commit is contained in:
Axel Kittenberger 2010-11-06 21:29:22 +00:00
parent 43be580976
commit 86596fe7bb

View File

@ -193,7 +193,6 @@ end)()
-- Holds information about one observed directory inclusively subdirs. -- Holds information about one observed directory inclusively subdirs.
-- --
local Sync = (function() local Sync = (function()
----- -----
-- Syncs that have no name specified get an incremental default name -- Syncs that have no name specified get an incremental default name
-- --
@ -261,17 +260,35 @@ local Sync = (function()
end end
end end
-----
-- Return the nearest alarm for this Sync.
--
local function getAlarm(self)
-- first checks if more processses could be spawned
if self.processes:size() >= self.config.maxProcesses then
return nil
end
if self.delays[1] then
return self.delays[1].alarm
end
end
----- -----
-- Creates a new Sync -- Creates a new Sync
-- --
local function new(config) local function new(config)
local s = { local s = {
-- TODO document.
config = config, config = config,
delays = CountArray.new(), delays = CountArray.new(),
delayname = {}, delayname = {},
source = config.source, source = config.source,
processes = CountArray.new(), processes = CountArray.new(),
-- functions
delay = delay, delay = delay,
getAlarm = getAlarm,
} }
-- provides a default name if needed -- provides a default name if needed
if not config.name then if not config.name then
@ -1003,21 +1020,27 @@ end
-- --
function lsyncd_get_alarm() function lsyncd_get_alarm()
local alarm = false local alarm = false
for _, s in Syncs.iwalk() do
-- TODO better handling of stati. ----
if s.delays[1] and -- checks if current nearest alarm or a is earlier
s.processes:size() < s.config.maxProcesses then --
if alarm then local function checkAlarm(a)
alarm = lsyncd.earlier(alarm, s.delays[1].alarm) if not a then
return
end
if not alarm then
alarm = a
else else
alarm = s.delays[1].alarm alarm = lsyncd.earlier(alarm, a)
end end
end end
-- checks all syncs for their earliest alarm
for _, s in Syncs.iwalk() do
checkAlarm(s:getAlarm())
end end
local sa = StatusFile.getAlarm() -- checks if a statusfile write has been delayed
if sa then checkAlarm(StatusFile.getAlarm())
alarm = (alarm and lsyncd.earlier(sa, alarm)) or sa
end
log("Debug", "lysncd_get_alarm returns: ",alarm) log("Debug", "lysncd_get_alarm returns: ",alarm)
return alarm return alarm