From 8f35924d0542780db7e5e62e712e3f23e5a3e0b9 Mon Sep 17 00:00:00 2001 From: Gordon Hecker Date: Thu, 22 Oct 2009 13:06:04 +0200 Subject: [PATCH] Use rsync to copy files locally. Rsync removes partial destination files when interrupted. This fixes a bug of partial results being left on local servers or in the cache. An error was reported in that case, but no cleanup was done automatically. Signed-off-by: Gordon Hecker --- Changelog | 2 ++ generic/transport.lua | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index 39b3f2d..1087b10 100644 --- a/Changelog +++ b/Changelog @@ -15,6 +15,8 @@ NEXT: * unused code was removed * the faq section in the documentation was extended * outdated documentation was removed + * a bug was fixed that lead to partial results being left on local servers + or in the cache when copying was interrupted e2factory-2.3.1 * bugfixes diff --git a/generic/transport.lua b/generic/transport.lua index 6be5654..f72129f 100644 --- a/generic/transport.lua +++ b/generic/transport.lua @@ -225,9 +225,12 @@ function push_file(sourcefile, durl, location, push_permissions) -- created parent directories, too. local dirs = e2lib.parentdirs(destdir) local mkdir_perm = "" + local rsync_perm = "" if push_permissions then mkdir_perm = string.format("--mode \"%s\"", push_permissions) + rsync_perm = string.format("--perms --chmod \"%s\"", + push_permissions) end for _,d in ipairs(dirs) do local mkdir_flags = string.format("-p %s", mkdir_perm) @@ -236,17 +239,12 @@ function push_file(sourcefile, durl, location, push_permissions) return false, e:cat(re) end end - local dst = string.format("%s/%s", destdir, destname) - rc, re = e2lib.cp(sourcefile, dst) + local args = string.format("%s '%s' '%s/%s'", rsync_perm, + sourcefile, destdir, destname) + rc, re = e2lib.rsync(args) if not rc then return false, re end - if push_permissions then - rc, re = e2lib.chmod(push_permissions, dst) - if not rc then - return false, re - end - end elseif u.transport == "rsync+ssh" then local destdir = string.format("/%s", e2lib.dirname(u.path)) local destname = e2lib.basename(u.path) @@ -297,6 +295,8 @@ function push_file(sourcefile, durl, location, push_permissions) end elseif u.transport == "scp" or u.transport == "ssh" then + -- scp does not remove partial destination files when + -- interrupted. Don't use. if push_permissions then e:append("ssh/scp transport does not support ".. "permission settings") -- 2.39.5