diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index 3709c84615..22f17091a1 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -181,14 +181,8 @@ module Cask # If an app folder is deleted, macOS considers the app uninstalled and removes some data. # Remove only the contents to handle this case. target.children.each do |child| - if target.writable? && !force - child.rmtree - else - Utils.gain_permissions_remove(child, command:) - end + Utils.gain_permissions_remove(child, command:) end - elsif target.parent.writable? && !force - target.rmtree else Utils.gain_permissions_remove(target, command:) end diff --git a/Library/Homebrew/test/cask/artifact/app_spec.rb b/Library/Homebrew/test/cask/artifact/app_spec.rb index 1b967d0886..667cbbc8c7 100644 --- a/Library/Homebrew/test/cask/artifact/app_spec.rb +++ b/Library/Homebrew/test/cask/artifact/app_spec.rb @@ -273,7 +273,7 @@ RSpec.describe Cask::Artifact::App, :cask do FileUtils.chmod 0544, target_path - expect { uninstall_phase }.to raise_error(Errno::ENOTEMPTY) + uninstall_phase expect(source_path).to be_a_directory end