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?
begin
tries ||= 2
@command.run("/usr/sbin/diskutil",
args: ["unmount", "force", mountpath],
print_stderr: false)
raise CaskError, "Failed to unmount #{mountpath}" if mountpath.exist?
tries ||= 3
if tries > 1
@command.run("/usr/sbin/diskutil",
args: ["eject", mountpath],
print_stderr: false)
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
raise e if (tries -= 1).zero?
sleep 1