diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-16 07:23:46 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-16 07:23:46 +0000 |
commit | 4110e5fa6213995e6c8561527e4c658e406405e9 (patch) | |
tree | a281bc406103d767ee89b8c0ae02997055a4237b | |
parent | 9c1588a86d98a5fba4abd63fcec7573bf8089b83 (diff) |
merge revision(s) 46783: [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_0_0@47974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | lib/fileutils.rb | 12 | ||||
-rw-r--r-- | test/fileutils/test_fileutils.rb | 6 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 23 insertions, 6 deletions
@@ -1,3 +1,8 @@ +Thu Oct 16 16:23:03 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com> + + * lib/fileutils.rb: handle ENOENT error with symlink targeted to + non-exists file. [ruby-dev:45933] [Bug #6716] + Wed Oct 15 16:23:22 2014 Tanaka Akira <akr@fsij.org> * test/ruby/test_time_tz.rb: Fix test error with tzdata-2014g. diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 13a4d152d0..43b3e1ce49 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -848,7 +848,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 @@ -1231,7 +1232,12 @@ module FileUtils end def exist? - lstat! ? true : false + begin + lstat + true + rescue Errno::ENOENT + false + end end def file? @@ -1549,7 +1555,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 diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index 640c3655f4..22f3e5864e 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -411,6 +411,12 @@ class TestFileUtils assert_raise(Errno::ELOOP) { mv 'tmp/symlink', 'tmp/symlink' } + # unexist symlink + File.symlink 'xxx', 'tmp/src' + assert_nothing_raised { + mv 'tmp/src', 'tmp/dest' + } + assert_equal true, File.symlink?('tmp/dest') end if have_symlink? def test_mv_pathname @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2014-10-15" -#define RUBY_PATCHLEVEL 585 +#define RUBY_RELEASE_DATE "2014-10-16" +#define RUBY_PATCHLEVEL 586 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 15 +#define RUBY_RELEASE_DAY 16 #include "ruby/version.h" |