From e2681c00889f41dc5c6725a4a11b8b074d207c69 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Thu, 16 Feb 2012 16:05:33 +0100 Subject: [PATCH] Fixing all kind of quirks in tests for Created dirctories by moving recursing logic into delay() --- default-direct.lua | 2 +- lsyncd.lua | 37 ++++++++++++++++++++----------------- tests/churn-direct.lua | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/default-direct.lua b/default-direct.lua index ca7a802..4bf6839 100644 --- a/default-direct.lua +++ b/default-direct.lua @@ -34,7 +34,7 @@ default.direct = { if event.isdir then spawn( event, - '/bin/mkdir', + '/bin/mkdir', '-p', event.targetPath ) else diff --git a/lsyncd.lua b/lsyncd.lua index 8e31d61..fd4cff3 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -1245,6 +1245,21 @@ local Sync = (function() -- local function delay(self, etype, time, path, path2) log('Function', 'delay(',self.config.name,', ',etype,', ',path,', ',path2,')') + + -- TODO + local function recurse() + if etype == 'Create' and path:byte(-1) == 47 then + local entries = lsyncd.readdir(self.source .. path) + if entries then + for dirname, isdir in pairs(entries) do + local pd = path .. dirname + if isdir then pd = pd..'/' end + log('Delay', 'Create creates Create on ',pd) + delay(self, 'Create', time, pd, nil) + end + end + end + end -- exclusion tests if not path2 then @@ -1273,18 +1288,6 @@ local Sync = (function() end end - if etype == 'Create' and path:byte(-1) == 47 then - local entries = lsyncd.readdir(self.source .. path) - if entries then - for dirname, isdir in pairs(entries) do - local pd = path .. dirname - if isdir then pd = pd..'/' end - log('Delay', 'Create creates Create on ',pd) - delay(self, 'Create', time, pd, nil) - end - end - end - if etype == 'Move' and not self.config.onMove then -- if there is no move action defined, -- split a move as delete/create @@ -1312,6 +1315,7 @@ local Sync = (function() stack(self.delays[self.delays.last], nd) end nd.dpos = Queue.push(self.delays, nd) + recurse() return end @@ -1324,25 +1328,23 @@ local Sync = (function() if ac then if ac == 'remove' then Queue.remove(self.delays, il) - return elseif ac == 'stack' then stack(od, nd) nd.dpos = Queue.push(self.delays, nd) - return elseif ac == 'absorb' then - return + -- nada elseif ac == 'replace' then od.etype = nd.etype od.path = nd.path od.path2 = nd.path2 - return elseif ac == 'split' then delay(self, 'Delete', time, path, nil) delay(self, 'Create', time, path2, nil) - return else error('unknown result of combine()') end + recurse() + return end il = il - 1 end @@ -1353,6 +1355,7 @@ local Sync = (function() end -- no block or combo nd.dpos = Queue.push(self.delays, nd) + recurse() end ----- diff --git a/tests/churn-direct.lua b/tests/churn-direct.lua index 49aac7f..8ef5339 100755 --- a/tests/churn-direct.lua +++ b/tests/churn-direct.lua @@ -14,7 +14,7 @@ local tdir, srcdir, trgdir = mktemps() -- makes some startup data churn(srcdir, 10) -local logs = {'-log', 'Exec' } +local logs = {'-log', 'Exec', '-log', 'Delay' } local pid = spawn( './lsyncd', '-nodaemon',