From d6688fc8ab67d26ca05373029129d7c204e69ed4 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Fri, 17 Feb 2012 09:12:01 +0100 Subject: [PATCH] just some superficial cleanup --- lsyncd.lua | 32 ++++++++++---------------------- tests/churn-rsync.lua | 6 +++--- tests/churn-rsyncssh.lua | 10 +++++----- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/lsyncd.lua b/lsyncd.lua index 319c2ab..465a91b 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -1813,12 +1813,9 @@ local Inotify = (function() -- local function removeWatch(path, core) local wd = pathwds[path] - if not wd then - return - end - if core then - lsyncd.inotify.rmwatch(wd) - end + if not wd then return end + if core then lsyncd.inotify.rmwatch(wd) end + wdpaths[wd] = nil pathwds[path] = nil end @@ -1837,18 +1834,17 @@ local Inotify = (function() return end - -- lets the core registers watch with the kernel - local wd = lsyncd.inotify.addwatch(path, - (settings and settings.inotifyMode) or ''); + -- registers the watch + local inotifyMode = (settings and settings.inotifyMode) or ''; + local wd = lsyncd.inotify.addwatch(path, inotifyMode); if wd < 0 then log('Inotify','Unable to add watch "',path,'"') return end do - -- If this wd is registered already the kernel - -- reused it for a new dir for a reason - old - -- dir is gone. + -- If this watch descriptor is registered already + -- the kernel reuses it since old dir is gone. local op = wdpaths[wd] if op and op ~= path then pathwds[op] = nil @@ -1858,16 +1854,10 @@ local Inotify = (function() wdpaths[wd] = path -- registers and adds watches for all subdirectories - -- and/or raises create events for all entries - local entries = lsyncd.readdir(path) if not entries then return end - for dirname, isdir in pairs(entries) do - local pd = path .. dirname - if isdir then pd = pd..'/' end - -- adds syncs for subdirs - if isdir then addWatch(pd) end + if isdir then addWatch(path .. dirname .. '/') end end end @@ -1878,9 +1868,7 @@ local Inotify = (function() -- rootdir: root dir to watch -- local function addSync(sync, rootdir) - if syncRoots[sync] then - error('duplicate sync in Inotify.addSync()') - end + if syncRoots[sync] then error('duplicate sync in Inotify.addSync()') end syncRoots[sync] = rootdir addWatch(rootdir) end diff --git a/tests/churn-rsync.lua b/tests/churn-rsync.lua index bf3ab17..d7378a2 100755 --- a/tests/churn-rsync.lua +++ b/tests/churn-rsync.lua @@ -5,13 +5,13 @@ require("posix") dofile("tests/testlib.lua") cwriteln("****************************************************************") -cwriteln(" Testing default.rsync with random data activity ") +cwriteln(" Testing default.rsync with random data activity") cwriteln("****************************************************************") local tdir, srcdir, trgdir = mktemps() --- makes some startup data -churn(srcdir, 10) +-- makes some startup data +churn(srcdir, 100) local logs = {} -- logs = {"-log", "Delay", "-log", "Fsevents" } diff --git a/tests/churn-rsyncssh.lua b/tests/churn-rsyncssh.lua index 30dc3ef..3300019 100755 --- a/tests/churn-rsyncssh.lua +++ b/tests/churn-rsyncssh.lua @@ -5,15 +5,15 @@ require("posix") dofile("tests/testlib.lua") cwriteln("****************************************************************"); -cwriteln(" Testing default.rsyncssh with random data activity "); +cwriteln(" Testing default.rsyncssh with random data activity"); cwriteln("****************************************************************"); -cwriteln(" (this test needs passwordless ssh localhost access "); -cwriteln(" for current user)"); +cwriteln("( this test needs passwordless ssh localhost access )"); +cwriteln("( for current user )"); local tdir, srcdir, trgdir = mktemps() --- makes some startup data -churn(srcdir, 10) +-- makes some startup data +churn(srcdir, 100) local logs = {} logs = {"-log", "Delay" }