mirror of
https://github.com/octoleo/lsyncd.git
synced 2025-01-07 09:04:05 +00:00
just some superficial cleanup
This commit is contained in:
parent
b334504c1c
commit
d6688fc8ab
32
lsyncd.lua
32
lsyncd.lua
@ -1813,12 +1813,9 @@ local Inotify = (function()
|
|||||||
--
|
--
|
||||||
local function removeWatch(path, core)
|
local function removeWatch(path, core)
|
||||||
local wd = pathwds[path]
|
local wd = pathwds[path]
|
||||||
if not wd then
|
if not wd then return end
|
||||||
return
|
if core then lsyncd.inotify.rmwatch(wd) end
|
||||||
end
|
|
||||||
if core then
|
|
||||||
lsyncd.inotify.rmwatch(wd)
|
|
||||||
end
|
|
||||||
wdpaths[wd] = nil
|
wdpaths[wd] = nil
|
||||||
pathwds[path] = nil
|
pathwds[path] = nil
|
||||||
end
|
end
|
||||||
@ -1837,18 +1834,17 @@ local Inotify = (function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lets the core registers watch with the kernel
|
-- registers the watch
|
||||||
local wd = lsyncd.inotify.addwatch(path,
|
local inotifyMode = (settings and settings.inotifyMode) or '';
|
||||||
(settings and settings.inotifyMode) or '');
|
local wd = lsyncd.inotify.addwatch(path, inotifyMode);
|
||||||
if wd < 0 then
|
if wd < 0 then
|
||||||
log('Inotify','Unable to add watch "',path,'"')
|
log('Inotify','Unable to add watch "',path,'"')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
-- If this wd is registered already the kernel
|
-- If this watch descriptor is registered already
|
||||||
-- reused it for a new dir for a reason - old
|
-- the kernel reuses it since old dir is gone.
|
||||||
-- dir is gone.
|
|
||||||
local op = wdpaths[wd]
|
local op = wdpaths[wd]
|
||||||
if op and op ~= path then
|
if op and op ~= path then
|
||||||
pathwds[op] = nil
|
pathwds[op] = nil
|
||||||
@ -1858,16 +1854,10 @@ local Inotify = (function()
|
|||||||
wdpaths[wd] = path
|
wdpaths[wd] = path
|
||||||
|
|
||||||
-- registers and adds watches for all subdirectories
|
-- registers and adds watches for all subdirectories
|
||||||
-- and/or raises create events for all entries
|
|
||||||
|
|
||||||
local entries = lsyncd.readdir(path)
|
local entries = lsyncd.readdir(path)
|
||||||
if not entries then return end
|
if not entries then return end
|
||||||
|
|
||||||
for dirname, isdir in pairs(entries) do
|
for dirname, isdir in pairs(entries) do
|
||||||
local pd = path .. dirname
|
if isdir then addWatch(path .. dirname .. '/') end
|
||||||
if isdir then pd = pd..'/' end
|
|
||||||
-- adds syncs for subdirs
|
|
||||||
if isdir then addWatch(pd) end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1878,9 +1868,7 @@ local Inotify = (function()
|
|||||||
-- rootdir: root dir to watch
|
-- rootdir: root dir to watch
|
||||||
--
|
--
|
||||||
local function addSync(sync, rootdir)
|
local function addSync(sync, rootdir)
|
||||||
if syncRoots[sync] then
|
if syncRoots[sync] then error('duplicate sync in Inotify.addSync()') end
|
||||||
error('duplicate sync in Inotify.addSync()')
|
|
||||||
end
|
|
||||||
syncRoots[sync] = rootdir
|
syncRoots[sync] = rootdir
|
||||||
addWatch(rootdir)
|
addWatch(rootdir)
|
||||||
end
|
end
|
||||||
|
@ -5,13 +5,13 @@ require("posix")
|
|||||||
dofile("tests/testlib.lua")
|
dofile("tests/testlib.lua")
|
||||||
|
|
||||||
cwriteln("****************************************************************")
|
cwriteln("****************************************************************")
|
||||||
cwriteln(" Testing default.rsync with random data activity ")
|
cwriteln(" Testing default.rsync with random data activity")
|
||||||
cwriteln("****************************************************************")
|
cwriteln("****************************************************************")
|
||||||
|
|
||||||
local tdir, srcdir, trgdir = mktemps()
|
local tdir, srcdir, trgdir = mktemps()
|
||||||
|
|
||||||
-- makes some startup data
|
-- makes some startup data
|
||||||
churn(srcdir, 10)
|
churn(srcdir, 100)
|
||||||
|
|
||||||
local logs = {}
|
local logs = {}
|
||||||
-- logs = {"-log", "Delay", "-log", "Fsevents" }
|
-- logs = {"-log", "Delay", "-log", "Fsevents" }
|
||||||
|
@ -5,15 +5,15 @@ require("posix")
|
|||||||
dofile("tests/testlib.lua")
|
dofile("tests/testlib.lua")
|
||||||
|
|
||||||
cwriteln("****************************************************************");
|
cwriteln("****************************************************************");
|
||||||
cwriteln(" Testing default.rsyncssh with random data activity ");
|
cwriteln(" Testing default.rsyncssh with random data activity");
|
||||||
cwriteln("****************************************************************");
|
cwriteln("****************************************************************");
|
||||||
cwriteln(" (this test needs passwordless ssh localhost access ");
|
cwriteln("( this test needs passwordless ssh localhost access )");
|
||||||
cwriteln(" for current user)");
|
cwriteln("( for current user )");
|
||||||
|
|
||||||
local tdir, srcdir, trgdir = mktemps()
|
local tdir, srcdir, trgdir = mktemps()
|
||||||
|
|
||||||
-- makes some startup data
|
-- makes some startup data
|
||||||
churn(srcdir, 10)
|
churn(srcdir, 100)
|
||||||
|
|
||||||
local logs = {}
|
local logs = {}
|
||||||
logs = {"-log", "Delay" }
|
logs = {"-log", "Delay" }
|
||||||
|
Loading…
Reference in New Issue
Block a user