From f816a39d1fbe1af4e5306ab9b8c940625d450f88 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera Date: Thu, 24 Apr 2025 18:03:07 +0800 Subject: [PATCH] cask/artifact/abstract_uninstall: fix `trash_paths` This is currently behaving incorrectly when calling `trash.swift` fails due to lack of permissions. In this instance, `trash.swift` prints error: permissionDenied to stdout, and this is incorrectly parsed as having successfully trashed a file named `error` and another named ` permissionDenied`. Let's fix this by ensuring that: - any paths in `trashed` are in the `paths` that we wanted to trash in the first place - define `untrashable` by removing the `trashed` paths from `paths` --- Library/Homebrew/cask/artifact/abstract_uninstall.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 0c9edb929d..8c0aa971bb 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -464,9 +464,9 @@ module Cask args: paths, print_stderr: Homebrew::EnvConfig.developer? - trashed, _, untrashable = stdout.partition("\n") - trashed = trashed.split(":") - untrashable = untrashable.split(":") + trashed, = stdout.partition("\n") + trashed = trashed.split(":") & paths + untrashable = paths - trashed trashed_with_permissions, untrashable = untrashable.partition do |path| Utils.gain_permissions(path, ["-R"], SystemCommand) do