Skip to content

Commit

Permalink
force permissions and delete ACLs if rmtree fails
Browse files Browse the repository at this point in the history
This logic is ugly as the installation directory will be left
in a mangled state if it fails partway through.  However, the
same is true when `rmtree` fails partway through, which this
code is intended to minimize.

References: Homebrew#5504
  • Loading branch information
rolandwalker committed Jul 31, 2014
1 parent 0c609fb commit c301b27
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,16 @@ def uninstall_artifacts
def purge_files
odebug "Purging files"
if @cask.destination_path.exist?
@cask.destination_path.rmtree
begin
@cask.destination_path.rmtree
rescue
# in case of permissions problems
if @cask.destination_path.exist?
@command.run('/bin/chmod', :args => ['-R', '--', 'u+rwx', @cask.destination_path])
@command.run('/bin/chmod', :args => ['-R', '-N', @cask.destination_path])
@cask.destination_path.rmtree
end
end
end
@cask.caskroom_path.rmdir_if_possible
end
Expand Down

0 comments on commit c301b27

Please sign in to comment.