summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--lib/fileutils.rb12
-rw-r--r--test/fileutils/test_fileutils.rb6
-rw-r--r--version.h2
4 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f2063870f..1f65e70b03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Oct 15 23:50:33 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 23:25:24 2014 NARUSE, Yui <naruse@ruby-lang.org>
* configure.in: NetBSD's ksh, used by configure, needs escapes.
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
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index c5f8734fea..6aa89c49ef 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -420,6 +420,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
diff --git a/version.h b/version.h
index a34f6bc45b..7dcdc5f5e7 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.4"
#define RUBY_RELEASE_DATE "2014-10-15"
-#define RUBY_PATCHLEVEL 253
+#define RUBY_PATCHLEVEL 254
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 10