From: Tobias Ulmer Date: Tue, 19 Aug 2014 13:36:06 +0000 (+0200) Subject: Handle fetching symlinks correctly, instead of creating 0 size file X-Git-Tag: e2factory-2.3.15rc1~192 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=7d8ceca318c692c03d5ac3b17ed82e0b5b361613;p=e2factory.git Handle fetching symlinks correctly, instead of creating 0 size file 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 --- diff --git a/generic/transport.lua b/generic/transport.lua index 4631ccc..06f2ccd 100644 --- a/generic/transport.lua +++ b/generic/transport.lua @@ -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