]> git.e2factory.org Git - e2factory.git/commitdiff
Use rsync to copy files locally. Rsync removes partial destination files
authorGordon Hecker <gh@emlix.com>
Thu, 22 Oct 2009 11:06:04 +0000 (13:06 +0200)
committerGordon Hecker <gh@emlix.com>
Thu, 22 Oct 2009 11:24:51 +0000 (13:24 +0200)
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 <gh@emlix.com>
Changelog
generic/transport.lua

index 39b3f2d1a006d657042c778452032bbb3ff68fc6..1087b10fbdfc8f70068d6973742770a9ef31761a 100644 (file)
--- 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
index 6be5654ca74082a414fd594649fe7f144cdb7671..f72129f3330ba98b48c504e6251e8bf72540289b 100644 (file)
@@ -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")