From 40ce23235ca8e0ff4fab92b8455baba19d6d3dba Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Wed, 27 Oct 2010 10:03:48 +0000 Subject: [PATCH] --- lsyncd-conf.lua | 16 ++++++++-------- lsyncd.c | 24 ++++++++++++++++++------ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/lsyncd-conf.lua b/lsyncd-conf.lua index 962494b..68ad57a 100644 --- a/lsyncd-conf.lua +++ b/lsyncd-conf.lua @@ -19,24 +19,24 @@ slowbash = { startup = function(source, target) log(NORMAL, "cp -r from "..source.." -> "..target) - return exec("/bin/bash", "-c", "cp -r \"$1\"* \"$2\"", "/bin/bash", - source, target) + return exec("/bin/bash", "-c", [[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]], + "/bin/bash", source, target) end, create = function(source, path, name, target) local src = source..path..name local trg = target..path..name log(NORMAL, "create from "..src.." -> "..trg) - return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash", - src, trg) + return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]], + "/bin/bash", src, trg) end, modify = function(source, path, name, target) local src = source..path..name local trg = target..path..name log(NORMAL, "modify from "..src.." -> "..trg) - return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash", - src, trg) + return exec("/bin/bash", "-c", slower..[[cp "$1" "$2"]], + "/bin/bash", src, trg) end, attrib = function(source, path, name, target) @@ -46,8 +46,8 @@ slowbash = { delete = function(source, path, name, target) log(NORMAL, "delete "..target..path..name) - return exec("/bin/bash", "-c", slower.."rm \"$1\"", "/bin/bash", - target..path..name) + return exec("/bin/bash", "-c", slower..[[rm "$1"]], + "/bin/bash", target..path..name) end, -- move = function(source, path, name, destpath, destname, target) diff --git a/lsyncd.c b/lsyncd.c index 57cc2df..bf08497 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -38,6 +38,18 @@ #include #include +/** + * Extended debugging, undefine these to enable respective parts. + */ +#define DBG_MASTERLOOP(x) + +/** + * Debugging definitions + */ +#ifndef DBG_MASTERLOOP +#define DBG_MASTERLOOP(x) { logstring(DEBUG, x); } +#endif + /** * Macros to compare times() values * (borrowed from linux/jiffies.h) @@ -881,7 +893,7 @@ masterloop(lua_State *L) if (have_alarm && time_before(alarm_time, now)) { /* there is a delay that wants to be handled already * thus do not read from inotify_fd and jump directly to its handling */ - logstring(DEBUG, "immediately handling delays."); + DBG_MASTERLOOP("immediately handling delays."); do_read = 0; } else { /* use select() to determine what happens next @@ -894,11 +906,11 @@ masterloop(lua_State *L) sigemptyset(&sigset); if (have_alarm) { - logstring(DEBUG, "going into timed select."); + DBG_MASTERLOOP("going into timed select."); tv.tv_sec = (alarm_time - now) / clocks_per_sec; tv.tv_nsec = (alarm_time - now) * 1000000000 / clocks_per_sec % 1000000000; } else { - logstring(DEBUG, "going into blocking select."); + DBG_MASTERLOOP("going into blocking select."); } /* if select returns a positive number there is data on inotify * on zero the timemout occured. */ @@ -908,9 +920,9 @@ masterloop(lua_State *L) &sigset); if (do_read > 0) { - logstring(DEBUG, "theres data on inotify."); + DBG_MASTERLOOP("theres data on inotify."); } else { - logstring(DEBUG, "core: select() timeout or signal."); + DBG_MASTERLOOP("core: select() timeout or signal."); } } @@ -943,7 +955,7 @@ masterloop(lua_State *L) FD_SET(inotify_fd, &readfds); do_read = pselect(inotify_fd + 1, &readfds, NULL, NULL, &tv, NULL); if (do_read > 0) { - logstring(DEBUG, "there is more data on inotify."); + DBG_MASTERLOOP("there is more data on inotify."); } } }