mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-11-10 15:20:58 +00:00
This commit is contained in:
parent
a636b31e9f
commit
4e284ff599
45
lsyncd.lua
45
lsyncd.lua
@ -74,6 +74,21 @@ local targets = {}
|
|||||||
--
|
--
|
||||||
local watches = {}
|
local watches = {}
|
||||||
|
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- a dictionary of all processes lsyncd spawned.
|
||||||
|
--
|
||||||
|
-- structure
|
||||||
|
-- [pid] = {
|
||||||
|
-- target ..
|
||||||
|
-- atpye ..
|
||||||
|
-- wd ..
|
||||||
|
-- sync ..
|
||||||
|
-- filename ..
|
||||||
|
--
|
||||||
|
local children = {}
|
||||||
|
|
||||||
|
|
||||||
------
|
------
|
||||||
-- TODO
|
-- TODO
|
||||||
local collapse_table = {
|
local collapse_table = {
|
||||||
@ -145,23 +160,33 @@ local function attend_dir(origin, path, parent)
|
|||||||
delay_action(CREATE, wd, sync, nil, nil)
|
delay_action(CREATE, wd, sync, nil, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register all subdirectories
|
-- registers and adds watches for all subdirectories
|
||||||
local subdirs = lsyncd.sub_dirs(op);
|
local subdirs = lsyncd.sub_dirs(op);
|
||||||
for i, dirname in ipairs(subdirs) do
|
for i, dirname in ipairs(subdirs) do
|
||||||
attend_dir(origin, path..dirname.."/", thiswatch)
|
attend_dir(origin, path..dirname.."/", thiswatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- Called from code whenever a child process finished and
|
||||||
|
-- zombie process was collected by core.
|
||||||
|
--
|
||||||
|
function lsyncd_collect_child(pid, exitcode)
|
||||||
|
local child = children[pid]
|
||||||
|
if child == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local sync = child.sync
|
||||||
|
local origin = sync.origin
|
||||||
|
log(DEBUG, "collected "..pid..": "..event_names[atpye].." "..origin.source.."/"..sync.path..child.filename..
|
||||||
|
" = "..exitcode)
|
||||||
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- TODO
|
-- TODO
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
local function invoke_action(target, delay)
|
local function invoke_action(target, delay)
|
||||||
-- .origin .. link to origin
|
|
||||||
-- .path .. relative path of dir
|
|
||||||
-- .parent .. link to parent directory in watches
|
|
||||||
-- or nil for origin
|
|
||||||
local sync = delay.sync
|
local sync = delay.sync
|
||||||
local origin = sync.origin
|
local origin = sync.origin
|
||||||
local actions = origin.actions
|
local actions = origin.actions
|
||||||
@ -196,6 +221,16 @@ local function invoke_action(target, delay)
|
|||||||
|
|
||||||
if func ~= nil then
|
if func ~= nil then
|
||||||
pid = func(origin.source, sync.path, delay.filename, target.ident)
|
pid = func(origin.source, sync.path, delay.filename, target.ident)
|
||||||
|
if pid ~= nil and pid > 0 then
|
||||||
|
child = {pid = pid,
|
||||||
|
target = target,
|
||||||
|
atpye = delay.atype,
|
||||||
|
wd = delay.wd,
|
||||||
|
sync = delay.sync,
|
||||||
|
filename = delay.filname
|
||||||
|
}
|
||||||
|
children[pid] = child,
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user