diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 2242b7961a..0c9edb929d 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -411,7 +411,7 @@ module Cask next end - if MacOS.undeletable?(resolved_path) + if undeletable?(resolved_path) opoo "Skipping #{Formatter.identifier(action)} for undeletable path '#{path}'." next end @@ -538,6 +538,10 @@ module Cask recursive_rmdir(*resolved_paths, **kwargs) end end + + def undeletable?(target); end end end end + +require "extend/os/cask/artifact/abstract_uninstall" diff --git a/Library/Homebrew/extend/os/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/extend/os/cask/artifact/abstract_uninstall.rb new file mode 100644 index 0000000000..9298c18f91 --- /dev/null +++ b/Library/Homebrew/extend/os/cask/artifact/abstract_uninstall.rb @@ -0,0 +1,5 @@ +# typed: strict +# frozen_string_literal: true + +require "extend/os/mac/cask/artifact/abstract_uninstall" if OS.mac? +require "extend/os/linux/cask/artifact/abstract_uninstall" if OS.linux? diff --git a/Library/Homebrew/extend/os/linux/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/extend/os/linux/cask/artifact/abstract_uninstall.rb new file mode 100644 index 0000000000..761fc2bc03 --- /dev/null +++ b/Library/Homebrew/extend/os/linux/cask/artifact/abstract_uninstall.rb @@ -0,0 +1,23 @@ +# typed: strict +# frozen_string_literal: true + +module OS + module Linux + module Cask + module Artifact + module AbstractUninstall + extend T::Helpers + + requires_ancestor { ::Cask::Artifact::AbstractUninstall } + + sig { params(target: Pathname).returns(T::Boolean) } + def undeletable?(target) + !target.parent.writable? + end + end + end + end + end +end + +Cask::Artifact::AbstractUninstall.prepend(OS::Linux::Cask::Artifact::AbstractUninstall) diff --git a/Library/Homebrew/extend/os/mac/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/extend/os/mac/cask/artifact/abstract_uninstall.rb new file mode 100644 index 0000000000..2871527d17 --- /dev/null +++ b/Library/Homebrew/extend/os/mac/cask/artifact/abstract_uninstall.rb @@ -0,0 +1,25 @@ +# typed: strict +# frozen_string_literal: true + +require "cask/macos" + +module OS + module Mac + module Cask + module Artifact + module AbstractUninstall + extend T::Helpers + + requires_ancestor { ::Cask::Artifact::AbstractUninstall } + + sig { params(target: Pathname).returns(T::Boolean) } + def undeletable?(target) + MacOS.undeletable?(target) + end + end + end + end + end +end + +Cask::Artifact::AbstractUninstall.prepend(OS::Mac::Cask::Artifact::AbstractUninstall)