From 60a14c262f04e3f5dabecda9b82c1fd4c68e1516 Mon Sep 17 00:00:00 2001 From: Axel Kittenberger Date: Sat, 13 Nov 2010 07:53:04 +0000 Subject: [PATCH] --- lsyncd-conf.lua => examples/lbash.lua | 25 ++++++++++--------------- examples/lrsync.lua | 12 ++++++++++++ lsyncd.lua | 18 ++++++++++++++---- 3 files changed, 36 insertions(+), 19 deletions(-) rename lsyncd-conf.lua => examples/lbash.lua (71%) create mode 100644 examples/lrsync.lua diff --git a/lsyncd-conf.lua b/examples/lbash.lua similarity index 71% rename from lsyncd-conf.lua rename to examples/lbash.lua index 60ee748..c967d75 100644 --- a/lsyncd-conf.lua +++ b/examples/lbash.lua @@ -1,11 +1,10 @@ ---- -- User configuration file for lsyncd. --- --- TODO documentation- +-- +-- This example uses local bash commands to keep two local +-- directory trees in sync. -- settings = { --- logfile = "/tmp/lsyncd", --- nodaemon = true, statusFile = "/tmp/lsyncd.stat", statusIntervall = 1, } @@ -26,10 +25,6 @@ slowbash = { event.source, event.target) end, - onModify = function(event) - spawn(event, "/home/axel/lsyncd2/in", "<", "tuhutu\n", "2") - end, - onCreate = function(event) local s = event.sourcePathname local t = event.targetPathname @@ -37,12 +32,12 @@ slowbash = { spawnShell(event, prefix..[[cp -r "$1" "$2"]], s, t) end, --- onModify = function(event) --- local s = event.sourcePathname --- local t = event.targetPathname --- log("Normal", "Spawning Modify ",s," -> ",t) --- spawnShell(event, prefix..[[cp -r "$1" "$2"]], s, t) --- end, + onModify = function(event) + local s = event.sourcePathname + local t = event.targetPathname + log("Normal", "Spawning Modify ",s," -> ",t) + spawnShell(event, prefix..[[cp -r "$1" "$2"]], s, t) + end, onDelete = function(event) local t = event.targetPathname @@ -58,5 +53,5 @@ slowbash = { end, } -sync{default.rsync, source="s", target="d/"} +sync{default.rsync, source="src", target="dst/"} diff --git a/examples/lrsync.lua b/examples/lrsync.lua new file mode 100644 index 0000000..56e3ed4 --- /dev/null +++ b/examples/lrsync.lua @@ -0,0 +1,12 @@ +---- +-- User configuration file for lsyncd. +-- +-- Simple example for default rsync. +-- +settings = { + statusFile = "/tmp/lsyncd.stat", + statusIntervall = 1, +} + +sync{default.rsync, source="src", target="dst/"} + diff --git a/lsyncd.lua b/lsyncd.lua index 0500ece..281a355 100644 --- a/lsyncd.lua +++ b/lsyncd.lua @@ -798,10 +798,20 @@ local Sync = (function() od.etype," on ",path) return elseif c == 2 then - log("Delay",nd.etype," replaces event ", - od.etype," on ",path) - self.delays[il] = nd - -- TODO turn moveFroms into deletes. + if od.etype ~= "Move" then + log("Delay",nd.etype," replaces event ", + od.etype," on ",path) + od.etype = nd.etype + if od.path ~= nd.path then + error("Cannot replace events with different paths") + end + else + log("Delay",nd.etype," turns a move into delete ", + od.etype," on ", path) + od.etype = "Delete" + od.path2 = nil + table.insert(self.delays, nd) + end return elseif c == 3 then log("Delay", "Stacking ",nd.etype," upon ",