diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-15 14:51:58 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-15 14:51:58 +0000 |
commit | 3d22fe530bd605bfe2cbdadd024fcb37fbbcae16 (patch) | |
tree | 04989baca0ffef375df367f1bd9b68a8a7c25478 /lib | |
parent | da85f4ee544634c66c32028018bb8042d00cd73b (diff) |
merge revision(s) r46783: [Backport #6716]
* lib/fileutils.rb: handle ENOENT error with symlink targeted to
non-exists file. [ruby-dev:45933] [Bug #6716]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fileutils.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 99044e2cd6..335d60d4a2 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -854,7 +854,8 @@ module FileUtils fu_check_options options, OPT_TABLE['install'] fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose] return if options[:noop] - fu_each_src_dest(src, dest) do |s, d, st| + fu_each_src_dest(src, dest) do |s, d| + st = File.stat(s) unless File.exist?(d) and compare_file(s, d) remove_file d, true copy_file s, d @@ -1252,7 +1253,12 @@ module FileUtils end def exist? - lstat! ? true : false + begin + lstat + true + rescue Errno::ENOENT + false + end end def file? @@ -1570,7 +1576,7 @@ module FileUtils def fu_each_src_dest(src, dest) #:nodoc: fu_each_src_dest0(src, dest) do |s, d| raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d) - yield s, d, File.stat(s) + yield s, d end end private_module_function :fu_each_src_dest |