Skip to content

Commit

Permalink
Use diskutil eject instead of hdiutil detach
Browse files Browse the repository at this point in the history
  • Loading branch information
bacongravy committed Feb 11, 2019
1 parent b0bb3ee commit 4888511
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/macinbox/actions/create_image_from_installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def enable_hidpi

def save_image
Logger.info "Saving the image..." do
@scratch_disk.detach
@scratch_disk.eject
FileUtils.chown ENV["SUDO_USER"], nil, @scratch_image
FileUtils.mv @scratch_image, @output_path
end
Expand Down
11 changes: 3 additions & 8 deletions lib/macinbox/virtual_disk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def unmount_efi
Task.run %W[ /usr/sbin/diskutil unmount #{@efi_device} ] + @task_opts
end

def detach
def eject
max_attempts = 5
for attempt in 1..max_attempts
begin
Logger.info "Detaching the image..." if @debug
Task.run %W[ /usr/bin/hdiutil detach #{@disk_device} ] + @quiet_flag
quiet = @debug ? [] : %W[ quiet ]
Task.run %W[ /usr/sbin/diskutil ] + quiet + %W[ eject #{@disk_device} ] + @task_opts
unset_devices
break
rescue Macinbox::Error => error
Expand All @@ -81,11 +81,6 @@ def detach
end
end

def eject
Task.run %W[ /usr/sbin/diskutil eject #{@disk_device} ] + @task_opts
unset_devices
end

def detach!
return unless @disk_device
%x( /usr/bin/hdiutil detach -quiet -force #{@disk_device.shellescape} > /dev/null 2>&1 )
Expand Down

0 comments on commit 4888511

Please sign in to comment.