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( local paths = elist.getPaths(
function(etype, path1, path2) function(etype, path1, path2)
if string.byte(path1, -1) == 47 and if string.byte(path1, -1) == 47 and etype == 'Delete' then
(etype == 'Delete' or etype == 'Create')
then
return sub(path1)..'***', sub(path2) return sub(path1)..'***', sub(path2)
else else
return sub(path1), sub(path2) return sub(path1), sub(path2)

View File

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

View File

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