mirror of https://github.com/octoleo/lsyncd.git
fixing excludes on startup
This commit is contained in:
parent
a996c1ae1a
commit
7835de7c7b
78
lsyncd.lua
78
lsyncd.lua
|
@ -862,6 +862,20 @@ local InletFactory = (function()
|
||||||
sync:rmExclude(pattern)
|
sync:rmExclude(pattern)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
-----
|
||||||
|
-- gets the list of excludes in their original rsynlike patterns form.
|
||||||
|
--
|
||||||
|
getExcludes = function(sync)
|
||||||
|
-- creates a copy
|
||||||
|
local e = {}
|
||||||
|
local en = 1;
|
||||||
|
for _, v in pairs(sync.excludes.list) do
|
||||||
|
e[en] = v;
|
||||||
|
en = en + 1;
|
||||||
|
end
|
||||||
|
return e;
|
||||||
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
-- Creates a blanketEvent that blocks everything
|
-- Creates a blanketEvent that blocks everything
|
||||||
-- and is blocked by everything.
|
-- and is blocked by everything.
|
||||||
|
@ -1258,13 +1272,13 @@ local Sync = (function()
|
||||||
|
|
||||||
-- exclusion tests
|
-- exclusion tests
|
||||||
if not path2 then
|
if not path2 then
|
||||||
-- simple test for 1 path events
|
-- simple test for single path events
|
||||||
if self.excludes:test(path) then
|
if self.excludes:test(path) then
|
||||||
log("Exclude", "excluded ",etype," on '",path,"'")
|
log("Exclude", "excluded ",etype," on '",path,"'")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- for 2 paths (move) it might result into a split
|
-- for double paths (move) it might result into a split
|
||||||
local ex1 = self.excludes:test(path)
|
local ex1 = self.excludes:test(path)
|
||||||
local ex2 = self.excludes:test(path2)
|
local ex2 = self.excludes:test(path2)
|
||||||
if ex1 and ex2 then
|
if ex1 and ex2 then
|
||||||
|
@ -3116,12 +3130,28 @@ local default_rsync = {
|
||||||
if string.sub(config.target, -1) ~= "/" then
|
if string.sub(config.target, -1) ~= "/" then
|
||||||
config.target = config.target .. "/"
|
config.target = config.target .. "/"
|
||||||
end
|
end
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
|
||||||
" -> ", config.target)
|
local excludes = inlet.getExcludes();
|
||||||
spawn(event, "/usr/bin/rsync",
|
if #excludes == 0 then
|
||||||
"--delete",
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
config.rsyncOps, "-r",
|
" -> ", config.target)
|
||||||
config.source, config.target)
|
spawn(event, "/usr/bin/rsync",
|
||||||
|
"--delete",
|
||||||
|
config.rsyncOps, "-r",
|
||||||
|
config.source,
|
||||||
|
config.target)
|
||||||
|
else
|
||||||
|
local exS = table.concat(excludes, "\n")
|
||||||
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
|
" -> ", config.target," excluding\n", exS)
|
||||||
|
spawn(event, "/usr/bin/rsync",
|
||||||
|
"<", exS,
|
||||||
|
"--exclude-from=-",
|
||||||
|
"--delete",
|
||||||
|
config.rsyncOps, "-r",
|
||||||
|
config.source,
|
||||||
|
config.target)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
@ -3276,14 +3306,30 @@ local default_rsyncssh = {
|
||||||
if string.sub(config.targetdir, -1) ~= "/" then
|
if string.sub(config.targetdir, -1) ~= "/" then
|
||||||
config.targetdir = config.targetdir .. "/"
|
config.targetdir = config.targetdir .. "/"
|
||||||
end
|
end
|
||||||
log("Normal", "recursive startup rsync: ", config.source,
|
|
||||||
" -> ", config.host .. ":" .. config.targetdir)
|
local excludes = inlet.getExcludes();
|
||||||
spawn(event, "/usr/bin/rsync",
|
if #excludes == 0 then
|
||||||
"--delete",
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
"-r",
|
" -> ", config.host .. ":" .. config.targetdir)
|
||||||
config.rsyncOps,
|
spawn(event, "/usr/bin/rsync",
|
||||||
config.source,
|
"--delete",
|
||||||
config.host .. ":" .. config.targetdir)
|
"-r",
|
||||||
|
config.rsyncOps,
|
||||||
|
config.source,
|
||||||
|
config.host .. ":" .. config.targetdir)
|
||||||
|
else
|
||||||
|
local exS = table.concat(excludes, "\n")
|
||||||
|
log("Normal", "recursive startup rsync: ", config.source,
|
||||||
|
" -> ", config.host .. ":" .. config.targetdir, " excluding\n")
|
||||||
|
spawn(event, "/usr/bin/rsync",
|
||||||
|
"<", exS,
|
||||||
|
"--exclude-from=-",
|
||||||
|
"--delete",
|
||||||
|
"-r",
|
||||||
|
config.rsyncOps,
|
||||||
|
config.source,
|
||||||
|
config.host .. ":" .. config.targetdir)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
Loading…
Reference in New Issue