Skip to content

Commit

Permalink
Report non-empty directories [ci skip]
Browse files Browse the repository at this point in the history
No longer used or generated files/directories sometimes remain
unremoved.
  • Loading branch information
nobu committed Mar 9, 2024
1 parent 2976d91 commit d94ad00
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tool/rbuninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def message(str = nil)
$dirs.each do |dir|
unlink[dir] = true
end
nonempty = {}
while dir = $dirs.pop
dir = File.dirname(dir) while File.basename(dir) == '.'
message "rmdir #{dir}"
Expand All @@ -76,16 +77,23 @@ def message(str = nil)
raise unless File.symlink?(realdir)
File.unlink(realdir)
end
rescue Errno::ENOENT, Errno::ENOTEMPTY
rescue Errno::ENOTEMPTY
nonempty[dir] = true
rescue Errno::ENOENT
rescue
status = false
puts $!
else
nonempty.delete(dir)
parent = File.dirname(dir)
$dirs.push(parent) unless parent == dir or unlink[parent]
end
end
end
message
unless nonempty.empty?
puts "Non empty director#{nonempty.size == 1 ? 'y' : 'ies'}:"
nonempty.each_key {|dir| print " #{dir}\n"}
end
exit(status)
}

0 comments on commit d94ad00

Please sign in to comment.