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
|
if event.isdir then
|
||||||
spawn(
|
spawn(
|
||||||
event,
|
event,
|
||||||
'/bin/mkdir',
|
'/bin/mkdir', '-p',
|
||||||
event.targetPath
|
event.targetPath
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
37
lsyncd.lua
37
lsyncd.lua
@ -1246,6 +1246,21 @@ local Sync = (function()
|
|||||||
local function delay(self, etype, time, path, path2)
|
local function delay(self, etype, time, path, path2)
|
||||||
log('Function', 'delay(',self.config.name,', ',etype,', ',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
|
-- exclusion tests
|
||||||
if not path2 then
|
if not path2 then
|
||||||
-- simple test for single path events
|
-- simple test for single path events
|
||||||
@ -1273,18 +1288,6 @@ local Sync = (function()
|
|||||||
end
|
end
|
||||||
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 etype == 'Move' and not self.config.onMove then
|
||||||
-- if there is no move action defined,
|
-- if there is no move action defined,
|
||||||
-- split a move as delete/create
|
-- split a move as delete/create
|
||||||
@ -1312,6 +1315,7 @@ local Sync = (function()
|
|||||||
stack(self.delays[self.delays.last], nd)
|
stack(self.delays[self.delays.last], nd)
|
||||||
end
|
end
|
||||||
nd.dpos = Queue.push(self.delays, nd)
|
nd.dpos = Queue.push(self.delays, nd)
|
||||||
|
recurse()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1324,25 +1328,23 @@ local Sync = (function()
|
|||||||
if ac then
|
if ac then
|
||||||
if ac == 'remove' then
|
if ac == 'remove' then
|
||||||
Queue.remove(self.delays, il)
|
Queue.remove(self.delays, il)
|
||||||
return
|
|
||||||
elseif ac == 'stack' then
|
elseif ac == 'stack' then
|
||||||
stack(od, nd)
|
stack(od, nd)
|
||||||
nd.dpos = Queue.push(self.delays, nd)
|
nd.dpos = Queue.push(self.delays, nd)
|
||||||
return
|
|
||||||
elseif ac == 'absorb' then
|
elseif ac == 'absorb' then
|
||||||
return
|
-- nada
|
||||||
elseif ac == 'replace' then
|
elseif ac == 'replace' then
|
||||||
od.etype = nd.etype
|
od.etype = nd.etype
|
||||||
od.path = nd.path
|
od.path = nd.path
|
||||||
od.path2 = nd.path2
|
od.path2 = nd.path2
|
||||||
return
|
|
||||||
elseif ac == 'split' then
|
elseif ac == 'split' then
|
||||||
delay(self, 'Delete', time, path, nil)
|
delay(self, 'Delete', time, path, nil)
|
||||||
delay(self, 'Create', time, path2, nil)
|
delay(self, 'Create', time, path2, nil)
|
||||||
return
|
|
||||||
else
|
else
|
||||||
error('unknown result of combine()')
|
error('unknown result of combine()')
|
||||||
end
|
end
|
||||||
|
recurse()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
il = il - 1
|
il = il - 1
|
||||||
end
|
end
|
||||||
@ -1353,6 +1355,7 @@ local Sync = (function()
|
|||||||
end
|
end
|
||||||
-- no block or combo
|
-- no block or combo
|
||||||
nd.dpos = Queue.push(self.delays, nd)
|
nd.dpos = Queue.push(self.delays, nd)
|
||||||
|
recurse()
|
||||||
end
|
end
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
@ -14,7 +14,7 @@ local tdir, srcdir, trgdir = mktemps()
|
|||||||
-- makes some startup data
|
-- makes some startup data
|
||||||
churn(srcdir, 10)
|
churn(srcdir, 10)
|
||||||
|
|
||||||
local logs = {'-log', 'Exec' }
|
local logs = {'-log', 'Exec', '-log', 'Delay' }
|
||||||
local pid = spawn(
|
local pid = spawn(
|
||||||
'./lsyncd',
|
'./lsyncd',
|
||||||
'-nodaemon',
|
'-nodaemon',
|
||||||
|
Loading…
Reference in New Issue
Block a user