move recursive Create creation on dirs into delays

This commit is contained in:
Axel Kittenberger 2012-02-16 15:36:28 +01:00
parent e0812e7e07
commit 83e1d22b2f
3 changed files with 22 additions and 13 deletions

View File

@ -45,9 +45,7 @@ default.rsync = {
local paths = elist.getPaths(
function(etype, path1, path2)
if string.byte(path1, -1) == 47 and
(etype == 'Delete' or etype == 'Create')
then
if string.byte(path1, -1) == 47 and etype == 'Delete' then
return sub(path1)..'***', sub(path2)
else
return sub(path1), sub(path2)

View File

@ -1135,8 +1135,7 @@ local Sync = (function()
end
-----
-- Returns true if this Sync concerns about
-- 'path'
-- Returns true if this Sync concerns about 'path'
--
local function concerns(self, path)
-- not concerned if watch rootdir doesnt match
@ -1274,6 +1273,18 @@ 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
@ -1853,18 +1864,18 @@ local Inotify = (function()
end
local entries = lsyncd.readdir(path)
if not entries then
return
end
if not entries then return end
for dirname, isdir in pairs(entries) do
local pd = path .. dirname
if isdir then pd = pd..'/' end
-- creates a Create event for entry.
if raiseSync then
local relative = splitPath(pd, syncRoots[raiseSync])
if relative then raiseSync:delay('Create', raiseTime, relative) end
end
-- No longer needed? (TODO)
-- if raiseSync then
-- local relative = splitPath(pd, syncRoots[raiseSync])
-- if relative then raiseSync:delay('Create', raiseTime, relative) end
-- end
-- adds syncs for subdirs
if isdir then addWatch(pd, true, raiseSync, raiseTime) end
end

View File

@ -14,7 +14,7 @@ local tdir, srcdir, trgdir = mktemps()
churn(srcdir, 10)
local logs = {}
logs = {"-log", "Delay", "-log", "Fsevents" }
-- logs = {"-log", "Delay", "-log", "Fsevents" }
local pid = spawn("./lsyncd", "-nodaemon", "-delay", "5",
"-rsync", srcdir, trgdir, unpack(logs))