[前][次][番号順一覧][スレッド一覧]

ruby-changes:73721

From: nagachika <ko1@a...>
Date: Sun, 25 Sep 2022 16:01:37 +0900 (JST)
Subject: [ruby-changes:73721] a07e7ad6b0 (ruby_3_1): merge revision(s) 70f69f85395f5735429cd45136d7de2742f08b72: [Backport #18941]

https://git.ruby-lang.org/ruby.git/commit/?id=a07e7ad6b0

From a07e7ad6b0b9abc44d097ca600b0ff801d0d0a06 Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Sun, 25 Sep 2022 15:18:36 +0900
Subject: merge revision(s) 70f69f85395f5735429cd45136d7de2742f08b72: [Backport
 #18941]

	[ruby/fileutils] Fix mkdir_p hanging on Windows when trying to create
	 a file on a offline drive

	https://github.com/ruby/fileutils/commit/9cc6a082d7
	---
	 lib/fileutils.rb                 | 2 +-
	 test/fileutils/test_fileutils.rb | 8 ++++++++
	 2 files changed, 9 insertions(+), 1 deletion(-)
---
 lib/fileutils.rb                 | 2 +-
 test/fileutils/test_fileutils.rb | 8 ++++++++
 version.h                        | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index c115005163..32968f0a1a 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -212,7 +212,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L212
       path = remove_trailing_slash(item)
 
       stack = []
-      until File.directory?(path)
+      until File.directory?(path) || File.dirname(path) == path
         stack.push path
         path = File.dirname(path)
       end
diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb
index 36b5d6ef50..9a648276fa 100644
--- a/test/fileutils/test_fileutils.rb
+++ b/test/fileutils/test_fileutils.rb
@@ -1098,6 +1098,14 @@ class TestFileUtils < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/fileutils/test_fileutils.rb#L1098
     ensure
       Dir.rmdir(drive) if drive and File.directory?(drive)
     end
+
+    def test_mkdir_p_offline_drive
+      offline_drive = ("A".."Z").to_a.reverse.find {|d| !File.exist?("#{d}:/") }
+
+      assert_raise(Errno::ENOENT) {
+        mkdir_p "#{offline_drive}:/new_dir"
+      }
+    end
   end
 
   def test_mkdir_p_file_perm
diff --git a/version.h b/version.h
index 70ce3a0bcd..01479b5b43 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 3
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 61
+#define RUBY_PATCHLEVEL 62
 
 #define RUBY_RELEASE_YEAR 2022
 #define RUBY_RELEASE_MONTH 9
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]