summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtx-rsync.lua
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2013-07-31 21:40:54 +0300
committerMarius <mariausol@gmail.com>2013-07-31 21:40:54 +0300
commit9bdf7ef9d9811adeab13e76766e170ca932fd7f2 (patch)
treef9dd7598f9581657dababa4085c445439e185b1f /scripts/context/lua/mtx-rsync.lua
parentb2ccd1eaf3c63a03928c81e5c0ffa6037c8ccd00 (diff)
downloadcontext-9bdf7ef9d9811adeab13e76766e170ca932fd7f2.tar.gz
beta 2013.07.31 20:23
Diffstat (limited to 'scripts/context/lua/mtx-rsync.lua')
-rw-r--r--scripts/context/lua/mtx-rsync.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/scripts/context/lua/mtx-rsync.lua b/scripts/context/lua/mtx-rsync.lua
index 65f795ee5..70a82e929 100644
--- a/scripts/context/lua/mtx-rsync.lua
+++ b/scripts/context/lua/mtx-rsync.lua
@@ -92,14 +92,20 @@ else
end
end
-function rsynccommand(dryrun,recurse,origin,target)
- local command = "rsync -ptlva "
+function rsynccommand(origin,target,dryrun,recurse,delete)
+ local command = "rsync -t -p "
if dryrun then
command = command .. "-n "
end
if recurse then
command = command .. "-r "
end
+ if delete then
+ if not recurse then
+ command = command .. "-d "
+ end
+ command = command .. "--delete "
+ end
return format('%s %s %s',command,origin,target)
end
@@ -109,7 +115,7 @@ local rsync = scripts.rsync
rsync.mode = "command"
-function rsync.run(origin,target,message,recurse)
+function rsync.run(origin,target,message,recurse,delete)
if type(origin) == "table" then
origin = concat(origin,"/")
end
@@ -127,15 +133,15 @@ function rsync.run(origin,target,message,recurse)
report_message(message)
end
if rsync.mode == "dryrun" then
- local command = rsynccommand(true,recurse,origin,target)
+ local command = rsynccommand(origin,target,true,recurse,delete)
report_dryrun(command.."\n")
os.execute(command)
elseif rsync.mode == "force" then
- local command = rsynccommand(false,recurse,origin,target)
+ local command = rsynccommand(origin,target,false,recurse,delete)
report_normal(command.."\n")
os.execute(command)
else
- local command = rsynccommand(true,recurse,origin,target)
+ local command = rsynccommand(origin,target,true,recurse,delete)
report_command(command)
end
end
@@ -154,8 +160,9 @@ function rsync.job(list)
local target = li.target
local message = li.message
local recurse = li.recurse
+ local delete = li.delete
if origin and #origin > 0 and target and #target > 0 then -- string or table
- rsync.run(origin,target,message,recurse)
+ rsync.run(origin,target,message,recurse,delete)
else
report_message("invalid job specification at index %s",i)
end