mirror of https://github.com/octoleo/lsyncd.git
This commit is contained in:
parent
417ddc79fe
commit
2bb0225f4e
|
@ -9,6 +9,7 @@ settings = {
|
||||||
loglevel = DEBUG,
|
loglevel = DEBUG,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print(bla)
|
||||||
|
|
||||||
------
|
------
|
||||||
-- for testing purposes
|
-- for testing purposes
|
||||||
|
|
33
lsyncd.c
33
lsyncd.c
|
@ -334,6 +334,20 @@ l_now(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns (on Lua stack) the addition of two clock_t times.
|
||||||
|
*
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
l_addup_clocks(lua_State *L)
|
||||||
|
{
|
||||||
|
clock_t c1 = luaL_checkinteger(L, 1);
|
||||||
|
clock_t c2 = luaL_checkinteger(L, 2);
|
||||||
|
lua_pop(L, 2);
|
||||||
|
lua_pushinteger(L, c1 + c2);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Executes a subprocess. Does not wait for it to return.
|
* Executes a subprocess. Does not wait for it to return.
|
||||||
*
|
*
|
||||||
|
@ -615,15 +629,16 @@ l_wait_pids(lua_State *L)
|
||||||
|
|
||||||
|
|
||||||
static const luaL_reg lsyncdlib[] = {
|
static const luaL_reg lsyncdlib[] = {
|
||||||
{"add_watch", l_add_watch },
|
{"addup_clocks", l_addup_clocks },
|
||||||
{"log", l_log },
|
{"add_watch", l_add_watch },
|
||||||
{"now", l_now },
|
{"log", l_log },
|
||||||
{"exec", l_exec },
|
{"now", l_now },
|
||||||
{"real_dir", l_real_dir },
|
{"exec", l_exec },
|
||||||
{"stackdump", l_stackdump },
|
{"real_dir", l_real_dir },
|
||||||
{"sub_dirs", l_sub_dirs },
|
{"stackdump", l_stackdump },
|
||||||
{"terminate", l_terminate },
|
{"sub_dirs", l_sub_dirs },
|
||||||
{"wait_pids", l_wait_pids },
|
{"terminate", l_terminate },
|
||||||
|
{"wait_pids", l_wait_pids },
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
26
lsyncd.lua
26
lsyncd.lua
|
@ -37,7 +37,7 @@ exec = lsyncd.exec
|
||||||
-- target = link to target directory
|
-- target = link to target directory
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
origins = {}
|
local origins = {}
|
||||||
|
|
||||||
----
|
----
|
||||||
-- a array of all targets
|
-- a array of all targets
|
||||||
|
@ -56,7 +56,7 @@ origins = {}
|
||||||
-- }
|
-- }
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
targets = {}
|
local targets = {}
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- all watches
|
-- all watches
|
||||||
|
@ -72,11 +72,11 @@ targets = {}
|
||||||
-- }
|
-- }
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
watches = {}
|
local watches = {}
|
||||||
|
|
||||||
------
|
------
|
||||||
-- TODO
|
-- TODO
|
||||||
collapse_table = {
|
local collapse_table = {
|
||||||
[ATTRIB] = { [ATTRIB] = ATTRIB, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE },
|
[ATTRIB] = { [ATTRIB] = ATTRIB, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE },
|
||||||
[MODIFY] = { [ATTRIB] = MODIFY, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE },
|
[MODIFY] = { [ATTRIB] = MODIFY, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE },
|
||||||
[CREATE] = { [ATTRIB] = CREATE, [MODIFY] = CREATE, [CREATE] = CREATE, [DELETE] = DELETE },
|
[CREATE] = { [ATTRIB] = CREATE, [MODIFY] = CREATE, [CREATE] = CREATE, [DELETE] = DELETE },
|
||||||
|
@ -100,7 +100,17 @@ local event_names = {
|
||||||
-- TODO
|
-- TODO
|
||||||
local function delay_action(atype, wd, sync, filename, time)
|
local function delay_action(atype, wd, sync, filename, time)
|
||||||
print("delay_action "..event_names[atype].."("..wd..") ")
|
print("delay_action "..event_names[atype].."("..wd..") ")
|
||||||
-- TODO
|
local origin = sync.origin
|
||||||
|
local target = origin.target
|
||||||
|
local delays = target.delays
|
||||||
|
local nd = {atype = atype,
|
||||||
|
wd = wd,
|
||||||
|
sync = sync,
|
||||||
|
filename = filename }
|
||||||
|
if time ~= nil and origin.actions.delay ~= nil then
|
||||||
|
nd.alarm = lsyncd.append_time(time, origin.actions.delay)
|
||||||
|
end
|
||||||
|
table.insert(delays, nd)
|
||||||
end
|
end
|
||||||
|
|
||||||
----
|
----
|
||||||
|
@ -141,6 +151,12 @@ local function attend_dir(origin, path, parent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
----
|
||||||
|
-- Called from core everytime after
|
||||||
|
function lsyncd_alarm()
|
||||||
|
-- TODO
|
||||||
|
end
|
||||||
|
|
||||||
----
|
----
|
||||||
-- Called from core on init or restart after user configuration.
|
-- Called from core on init or restart after user configuration.
|
||||||
--
|
--
|
||||||
|
|
Loading…
Reference in New Issue