aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rake/clean.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 03:07:37 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 03:07:37 +0000
commit6361928083d01906ab9d8782b6533b4ed7c834a0 (patch)
tree172488be8a74c9313d35b9cd7d53999cd55f561d /lib/rake/clean.rb
parent031e1570b934d6b3a1e17ae8eb78a44dac8186d3 (diff)
downloadruby-6361928083d01906ab9d8782b6533b4ed7c834a0.tar.gz
* lib/rake.rb, lib/rake/*.rb: Upgrade to rake-10.3.2
[fix GH-668] * test/rake/*.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rake/clean.rb')
-rw-r--r--lib/rake/clean.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb
index 8001ce569a..a49cd44167 100644
--- a/lib/rake/clean.rb
+++ b/lib/rake/clean.rb
@@ -31,9 +31,30 @@ module Rake
begin
rm_r file_name, opts
rescue StandardError => ex
- puts "Failed to remove #{file_name}: #{ex}"
+ puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name)
end
end
+
+ def file_already_gone?(file_name)
+ return false if File.exist?(file_name)
+
+ path = file_name
+ prev = nil
+
+ while path = File.dirname(path)
+ return false if cant_be_deleted?(path)
+ break if [prev, "."].include?(path)
+ prev = path
+ end
+ true
+ end
+ private_class_method :file_already_gone?
+
+ def cant_be_deleted?(path_name)
+ File.exist?(path_name) &&
+ (!File.readable?(path_name) || !File.executable?(path_name))
+ end
+ private_class_method :cant_be_deleted?
end
end