mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-13 14:43:09 +00:00
This commit is contained in:
parent
73a2074f11
commit
d37006c8eb
@ -22,29 +22,27 @@ slowbash = {
|
|||||||
return shell([[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], source, target)
|
return shell([[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], source, target)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
create = function(source, pathname, target)
|
create = function(self, unit)
|
||||||
local src = source..pathname
|
local event = unit:nextevent()
|
||||||
local trg = target..pathname
|
log(NORMAL, "create from "..event.spath.." -> "..event.tpath)
|
||||||
log(NORMAL, "create from "..src.." -> "..trg)
|
return shell(prefix..[[cp "$1" "$2"]], event.spath, event.tpath)
|
||||||
return shell(prefix..[[cp "$1" "$2"]], src, trg)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
modify = function(source, pathname, target)
|
modify = function(self, unit)
|
||||||
local src = source..pathname
|
local event = unit:nextevent()
|
||||||
local trg = target..pathname
|
log(NORMAL, "modify from "..event.spath.." -> "..event.tpath)
|
||||||
log(NORMAL, "modify from "..src.." -> "..trg)
|
return shell(prefix..[[cp "$1" "$2"]], event.spath, event.tpath)
|
||||||
return shell(prefix..[[cp "$1" "$2"]], src, trg)
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
attrib = function(source, path, name, target)
|
attrib = function(self, unit)
|
||||||
-- ignore attribs
|
-- ignore attribs
|
||||||
return 0
|
return 0
|
||||||
end,
|
end,
|
||||||
|
|
||||||
delete = function(source, pathname, target)
|
delete = function(self, unit)
|
||||||
local trg = target..pathname
|
local event = unit:nextevent()
|
||||||
log(NORMAL, "delete "..trg)
|
log(NORMAL, "delete "..event.tpath)
|
||||||
return exec(prefix..[[rm "$1"]], trg)
|
return exec(prefix..[[rm "$1"]], event.tpath)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- move = function(source, path, name, destpath, destname, target)
|
-- move = function(source, path, name, destpath, destname, target)
|
||||||
|
20
lsyncd.lua
20
lsyncd.lua
@ -402,6 +402,22 @@ function lsyncd_collect_process(pid, exitcode)
|
|||||||
origin.processes[pid] = nil
|
origin.processes[pid] = nil
|
||||||
end
|
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
|
-- TODO
|
||||||
--
|
--
|
||||||
@ -427,7 +443,9 @@ local function invoke_action(origin, delay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if func then
|
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
|
if pid and pid > 0 then
|
||||||
local process = {origin = origin,
|
local process = {origin = origin,
|
||||||
delay = delay
|
delay = delay
|
||||||
|
Loading…
Reference in New Issue
Block a user