diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index ed77239..d6994c9 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -22,29 +22,27 @@ slowbash = { return shell([[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], source, target) end, - create = function(source, pathname, target) - local src = source..pathname - local trg = target..pathname - log(NORMAL, "create from "..src.." -> "..trg) - return shell(prefix..[[cp "$1" "$2"]], src, trg) + create = function(self, unit) + local event = unit:nextevent() + log(NORMAL, "create from "..event.spath.." -> "..event.tpath) + return shell(prefix..[[cp "$1" "$2"]], event.spath, event.tpath) end, - modify = function(source, pathname, target) - local src = source..pathname - local trg = target..pathname - log(NORMAL, "modify from "..src.." -> "..trg) - return shell(prefix..[[cp "$1" "$2"]], src, trg) + modify = function(self, unit) + local event = unit:nextevent() + log(NORMAL, "modify from "..event.spath.." -> "..event.tpath) + return shell(prefix..[[cp "$1" "$2"]], event.spath, event.tpath) end, - attrib = function(source, path, name, target) + attrib = function(self, unit) -- ignore attribs return 0 end, - delete = function(source, pathname, target) - local trg = target..pathname - log(NORMAL, "delete "..trg) - return exec(prefix..[[rm "$1"]], trg) + delete = function(self, unit) + local event = unit:nextevent() + log(NORMAL, "delete "..event.tpath) + return exec(prefix..[[rm "$1"]], event.tpath) end, -- move = function(source, path, name, destpath, destname, target) diff --git a/lsyncd.lua b/lsyncd.lua index 7afd0b2..e92abc1 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -402,6 +402,22 @@ function lsyncd_collect_process(pid, exitcode) origin.processes[pid] = nil end +------ +-- TODO +-- +local unit = { + lsyncd_origin = true, + lsyncd_delay = true, + + nextevent = function(self) + return { + spath = self.lsyncd_origin.source..self.lsyncd_delay.pathname, + tpath = self.lsyncd_origin.targetident..self.lsyncd_delay.pathname, + } + end, +} + + ----- -- TODO -- @@ -427,7 +443,9 @@ local function invoke_action(origin, delay) end if func then - local pid = func(o.source, delay.pathname, o.targetident) + unit.lsyncd_origin = origin + unit.lsyncd_delay = delay + local pid = func(actions, unit) if pid and pid > 0 then local process = {origin = origin, delay = delay