Skip to content

Commit 73906c3

Browse files
committed
cask: show accurate log messages for in-place upgrades
When a terminal has App Management or Full Disk Access permissions, Homebrew upgrades cask apps in-place by replacing only the contents of the .app directory, preserving its inode and macOS metadata (Dock position, notification settings, granted permissions). However, the log output still printed "Removing App" and "Moving App" as if the entire bundle were being deleted and reinstalled. With this change: - In-place upgrades print a single "Upgrading App in-place" message - Full replacement upgrades continue to print "Removing App" and "Moving App" as before
1 parent 6e01bb1 commit 73906c3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Library/Homebrew/cask/artifact/moved.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ def move(adopt: false, auto_updates: false, force: false, verbose: false, predec
102102
end
103103
end
104104

105-
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
106-
107105
Utils.gain_permissions_mkpath(target.dirname, command:) unless target.dirname.exist?
108106

109107
if target.directory? && Quarantine.app_management_permissions_granted?(app: target, command:)
@@ -116,8 +114,10 @@ def move(adopt: false, auto_updates: false, force: false, verbose: false, predec
116114
Quarantine.copy_xattrs(source, target, command:)
117115
FileUtils.rm_r(source)
118116
elsif target.dirname.writable?
117+
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
119118
FileUtils.move(source, target)
120119
else
120+
ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'"
121121
# default sudo user isn't necessarily able to write to Homebrew's locations
122122
# e.g. with runas_default set in the sudoers (5) file.
123123
command.run!("/bin/cp", args: ["-pR", source, target], sudo: true)
@@ -179,20 +179,21 @@ def move_back(skip: false, force: false, adopt: false, command: nil, **options)
179179
end
180180

181181
def delete(target, force: false, successor: nil, command: nil, **_)
182-
ohai "Removing #{self.class.english_name} '#{target}'"
183182
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if undeletable?(target)
184183

185184
return unless Utils.path_occupied?(target)
186185

187186
if target.directory? && matching_artifact?(successor) && Quarantine.app_management_permissions_granted?(
188187
app: target, command:,
189188
)
189+
ohai "Upgrading #{self.class.english_name} '#{target}' in-place"
190190
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
191191
# Remove only the contents to handle this case.
192192
target.children.each do |child|
193193
Utils.gain_permissions_remove(child, command:)
194194
end
195195
else
196+
ohai "Removing #{self.class.english_name} '#{target}'"
196197
Utils.gain_permissions_remove(target, command:)
197198
end
198199
end

0 commit comments

Comments
 (0)