]> git.e2factory.org Git - e2factory.git/commitdiff
Handle fetching symlinks correctly, instead of creating 0 size file
authorTobias Ulmer <tu@emlix.com>
Tue, 19 Aug 2014 13:36:06 +0000 (15:36 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
This makes symlinks in proj/init work, and should also fix the use of
symlinks in other place. Also, the code should now detect other
non-regular files being fetched and return an error message in this case.

Fixes bz#141

Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/transport.lua

index 4631ccc7f39e488a804eea4978fa5473081df28a..06f2ccdb882190a444f54fba6cad8dc107269b06 100644 (file)
@@ -198,6 +198,13 @@ function transport.fetch_file(surl, location, destdir, destname)
     -- missing error detection.
     e2lib.rmtempfile(tmpfile_path)
 
+    -- Some tools (rsync) do not return an error code when skipping symlinks,
+    -- device files, etc. Thus we delete the tmp file here, let rsync do its
+    -- job, and detect the silent error condition when moving the file to its
+    -- final destination. Yes there is a race, but we take that chance over
+    -- missing error detection.
+    e2lib.rmtempfile(tmpfile_path)
+
     -- fetch the file to the temporary directory
     if u.transport == "http" or
         u.transport == "https" then
@@ -220,6 +227,7 @@ function transport.fetch_file(surl, location, destdir, destname)
     elseif u.transport == "file" then
         -- rsync "sourcefile" "destdir/destfile"
         local argv = {}
+        table.insert(argv, "-L") -- copy symlinks as real files.
         table.insert(argv, e2lib.join("/", u.path, location))
         table.insert(argv, tmpfile_path)
         rc, re = e2lib.rsync(argv)
@@ -259,8 +267,6 @@ function transport.fetch_file(surl, location, destdir, destname)
     if not rc then
         return false, e:cat(re)
     end
-    -- file was moved away above, but remove it from the list anyway
-    e2lib.rmtempfile(tmpfile_path)
     return true
 end