Skip to content

Commit

Permalink
Merge pull request #16894 from Homebrew/cask-fix-app-remove
Browse files Browse the repository at this point in the history
cask/artifact/moved: fix permission handling when removing directories
  • Loading branch information
Bo98 committed Mar 18, 2024
2 parents fbc2b7d + 011dfc8 commit 6cb0fd0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 1 addition & 7 deletions Library/Homebrew/cask/artifact/moved.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,8 @@ def delete(target, force: false, successor: nil, command: nil, **_)
# 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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/artifact/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@

FileUtils.chmod 0544, target_path

expect { uninstall_phase }.to raise_error(Errno::ENOTEMPTY)
uninstall_phase

expect(source_path).to be_a_directory
end
Expand Down

0 comments on commit 6cb0fd0

Please sign in to comment.