diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index e9012fe..700a8c0 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -9,6 +9,7 @@ settings = { loglevel = DEBUG, } +print(bla) ------ -- for testing purposes diff --git a/lsyncd.c b/lsyncd.c index 597dd08..9a91275 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -334,6 +334,20 @@ l_now(lua_State *L) 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. * @@ -615,15 +629,16 @@ l_wait_pids(lua_State *L) static const luaL_reg lsyncdlib[] = { - {"add_watch", l_add_watch }, - {"log", l_log }, - {"now", l_now }, - {"exec", l_exec }, - {"real_dir", l_real_dir }, - {"stackdump", l_stackdump }, - {"sub_dirs", l_sub_dirs }, - {"terminate", l_terminate }, - {"wait_pids", l_wait_pids }, + {"addup_clocks", l_addup_clocks }, + {"add_watch", l_add_watch }, + {"log", l_log }, + {"now", l_now }, + {"exec", l_exec }, + {"real_dir", l_real_dir }, + {"stackdump", l_stackdump }, + {"sub_dirs", l_sub_dirs }, + {"terminate", l_terminate }, + {"wait_pids", l_wait_pids }, {NULL, NULL} }; diff --git a/lsyncd.lua b/lsyncd.lua index b30c4f7..7473186 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -37,7 +37,7 @@ exec = lsyncd.exec -- target = link to target directory -- } -- -origins = {} +local origins = {} ---- -- a array of all targets @@ -56,7 +56,7 @@ origins = {} -- } -- } -- -targets = {} +local targets = {} ----- -- all watches @@ -72,11 +72,11 @@ targets = {} -- } -- } -- -watches = {} +local watches = {} ------ -- TODO -collapse_table = { +local collapse_table = { [ATTRIB] = { [ATTRIB] = ATTRIB, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE }, [MODIFY] = { [ATTRIB] = MODIFY, [MODIFY] = MODIFY, [CREATE] = CREATE, [DELETE] = DELETE }, [CREATE] = { [ATTRIB] = CREATE, [MODIFY] = CREATE, [CREATE] = CREATE, [DELETE] = DELETE }, @@ -100,7 +100,17 @@ local event_names = { -- TODO local function delay_action(atype, wd, sync, filename, time) 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 ---- @@ -141,6 +151,12 @@ local function attend_dir(origin, path, parent) end end +---- +-- Called from core everytime after +function lsyncd_alarm() + -- TODO +end + ---- -- Called from core on init or restart after user configuration. --