From a5384470727d9da82d4103e3eb83381f8939a6d5 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 17 Nov 2010 19:18:35 +0000 Subject: [PATCH] fixed move event on layer 3 binary calls --- examples/lecho.lua | 23 +++++++++++++++++++++++ lsyncd.lua | 12 ++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 examples/lecho.lua diff --git a/examples/lecho.lua b/examples/lecho.lua new file mode 100644 index 0000000..07f4bf9 --- /dev/null +++ b/examples/lecho.lua @@ -0,0 +1,23 @@ +----- +-- User configuration file for lsyncd. +-- +-- This example uses local bash commands to keep two local +-- directory trees in sync. +-- + +----- +-- for testing purposes. just echos what is happening. +-- +echo = { + maxProcesses = 1, + delay = 1, + onStartup = "/bin/echo telling about ^source", + onAttrib = "/bin/echo attrib ^pathname", + onCreate = "/bin/echo create ^pathname", + onDelete = "/bin/echo delete ^pathname", + onModify = "/bin/echo modify ^pathname", + onMove = "/bin/echo move ^o.pathname -> ^d.pathname", +} + +sync{echo, source="src", target="/path/to/trg/"} + diff --git a/lsyncd.lua b/lsyncd.lua index fb024b8..503e0f0 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -1686,7 +1686,7 @@ local functionWriter = (function() local haveEvent2 = false for ia, iv in ipairs(args) do - -- a list of arguments this arg is split to + -- a list of arguments this arg is being split into local a = {{true, iv}} -- goes through all translates for _, v in ipairs(transVars) do @@ -1696,6 +1696,9 @@ local functionWriter = (function() local pre, post = string.match(a[ai][2], "(.*)"..v[1].."(.*)") if pre then + if v[3] > 1 then + haveEvent2 = true + end if pre ~= "" then table.insert(a, ai, {true, pre}) ai = ai + 1 @@ -1710,16 +1713,17 @@ local functionWriter = (function() end end + -- concats the argument pieces into a string. local as = "" local first = true for _, v in ipairs(a) do if not first then - as = as .. " .. " + as = as.." .. " end if v[1] then - as = as .. '"' .. v[2] .. '"' + as = as..'"'..v[2]..'"' else - as = as .. v[2] + as = as..v[2] end first = false end