[ruby/fileutils] Fix cp_r with symlink root on Windows

Previously this would copy the symlink root as a symlink instead
of creating a new root directory.  This modifies the source
to expand it using File.realpath before starting the copy.

Fixes Ruby Bug 12123

https://github.com/ruby/fileutils/commit/7359cef359
This commit is contained in:
Jeremy Evans 2019-08-23 14:52:12 -07:00 committed by Hiroshi SHIBATA
parent 9792c9d183
commit 06c35cfa65
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -488,7 +488,11 @@ module FileUtils
# If +remove_destination+ is true, this method removes each destination file before copy.
#
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
Entry_.new(src, nil, dereference_root).wrap_traverse(proc do |ent|
if dereference_root
src = File.realpath(src)
end
Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
destent = Entry_.new(dest, ent.rel, false)
File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
ent.copy destent.path