mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-11-10 15:20:58 +00:00
Fixing all kind of quirks in tests for Created dirctories by moving recursing logic into delay()
This commit is contained in:
parent
83e1d22b2f
commit
e2681c0088
@ -34,7 +34,7 @@ default.direct = {
|
||||
if event.isdir then
|
||||
spawn(
|
||||
event,
|
||||
'/bin/mkdir',
|
||||
'/bin/mkdir', '-p',
|
||||
event.targetPath
|
||||
)
|
||||
else
|
||||
|
37
lsyncd.lua
37
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
|
||||
|
||||
-----
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user