This commit is contained in:
Axel Kittenberger 2010-11-01 14:16:35 +00:00
parent 73a2074f11
commit d37006c8eb
2 changed files with 32 additions and 16 deletions

View File

@ -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)

View File

@ -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