Update dmg.rb based on feedback

Try "diskutil eject" twice before "diskutil unmount force".
This commit is contained in:
Trevor Powell 2017-01-30 22:31:09 -06:00 committed by GitHub
parent 4ce6616f2e
commit e11b8b68cd

View File

@ -43,12 +43,17 @@ module Hbc
next unless mountpath.exist? next unless mountpath.exist?
begin begin
tries ||= 2 tries ||= 3
@command.run("/usr/sbin/diskutil", if tries > 1
args: ["unmount", "force", mountpath], @command.run("/usr/sbin/diskutil",
print_stderr: false) args: ["eject", mountpath],
print_stderr: false)
raise CaskError, "Failed to unmount #{mountpath}" if mountpath.exist? else
@command.run("/usr/sbin/diskutil",
args: ["unmount", "force", mountpath],
print_stderr: false)
end
raise CaskError, "Failed to eject #{mountpath}" if mountpath.exist?
rescue CaskError => e rescue CaskError => e
raise e if (tries -= 1).zero? raise e if (tries -= 1).zero?
sleep 1 sleep 1