diff options
author | Marius <mariausol@gmail.com> | 2013-10-20 01:20:14 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-10-20 01:20:14 +0300 |
commit | 965214d981e6129b782c67adcaf3a81aedcb0bac (patch) | |
tree | 84f5945aae8efc9b6eb1898b873be5453cafe43d /scripts/context/lua/mtx-rsync.lua | |
parent | e7d0d90a434e5452ff9e86c8abab5a4cac35e2f1 (diff) | |
download | context-965214d981e6129b782c67adcaf3a81aedcb0bac.tar.gz |
stable 2013.05.28 00:36
Diffstat (limited to 'scripts/context/lua/mtx-rsync.lua')
-rw-r--r-- | scripts/context/lua/mtx-rsync.lua | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/scripts/context/lua/mtx-rsync.lua b/scripts/context/lua/mtx-rsync.lua index 53cabbe4f..65f795ee5 100644 --- a/scripts/context/lua/mtx-rsync.lua +++ b/scripts/context/lua/mtx-rsync.lua @@ -92,26 +92,13 @@ else end end -function rsynccommand(origin,target,dryrun,recurse,delete,exclude) - local command = "rsync -t -p" +function rsynccommand(dryrun,recurse,origin,target) + local command = "rsync -ptlva " if dryrun then - command = command .. " -n" + command = command .. "-n " end if recurse then - command = command .. " -r" - end - if type(exclude) == "table" then - for i=1,#exclude do - local e = exclude[i] - if e then - command = command .. ' --exclude "' .. e .. '"' - end - end - elseif type(exclude) == "string" then - command = command .. " --exclude-from " .. exclude - end - if delete and recurse then - command = command .. " --delete" + command = command .. "-r " end return format('%s %s %s',command,origin,target) end @@ -122,7 +109,7 @@ local rsync = scripts.rsync rsync.mode = "command" -function rsync.run(origin,target,message,recurse,delete,exclude) +function rsync.run(origin,target,message,recurse) if type(origin) == "table" then origin = concat(origin,"/") end @@ -140,15 +127,15 @@ function rsync.run(origin,target,message,recurse,delete,exclude) report_message(message) end if rsync.mode == "dryrun" then - local command = rsynccommand(origin,target,true,recurse,delete,exclude) + local command = rsynccommand(true,recurse,origin,target) report_dryrun(command.."\n") os.execute(command) elseif rsync.mode == "force" then - local command = rsynccommand(origin,target,false,recurse,delete,exclude) + local command = rsynccommand(false,recurse,origin,target) report_normal(command.."\n") os.execute(command) else - local command = rsynccommand(origin,target,true,recurse,delete,exclude) + local command = rsynccommand(true,recurse,origin,target) report_command(command) end end @@ -167,10 +154,8 @@ function rsync.job(list) local target = li.target local message = li.message local recurse = li.recurse - local delete = li.delete - local exclude = li.exclude if origin and #origin > 0 and target and #target > 0 then -- string or table - rsync.run(origin,target,message,recurse,delete,exclude) + rsync.run(origin,target,message,recurse) else report_message("invalid job specification at index %s",i) end |