From 1406ee7eac845069cc4fefac0820b0d0248691bc Mon Sep 17 00:00:00 2001 From: Steven Peters Date: Wed, 8 May 2019 11:29:37 -0700 Subject: [PATCH] abstract_uninstall: add timeout to trash_paths --- .../cask/artifact/abstract_uninstall.rb | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/cask/artifact/abstract_uninstall.rb b/Library/Homebrew/cask/artifact/abstract_uninstall.rb index 82aa4fd467..d0ca32acf0 100644 --- a/Library/Homebrew/cask/artifact/abstract_uninstall.rb +++ b/Library/Homebrew/cask/artifact/abstract_uninstall.rb @@ -324,20 +324,27 @@ module Cask set item i of argv to (item i of argv as POSIX file) end repeat - tell application "Finder" - set trashedItems to (move argv to trash) - set output to "" + try + with timeout of 30 seconds + tell application "Finder" + set trashedItems to (move argv to trash) + set output to "" - repeat with i from 1 to (count trashedItems) - set trashedItem to POSIX path of (item i of trashedItems as string) - set output to output & trashedItem - if i < count trashedItems then - set output to output & character id 0 - end if - end repeat + repeat with i from 1 to (count trashedItems) + set trashedItem to POSIX path of (item i of trashedItems as string) + set output to output & trashedItem + if i < count trashedItems then + set output to output & character id 0 + end if + end repeat - return output - end tell + return output + end tell + end timeout + on error + -- Ignore errors (probably running under Azure) + return 0 + end try end run APPLESCRIPT