grahampugh / erase-install

A script that automates downloading macOS installers, and optionally erasing or upgrading macOS in a single process. Watch the video!
https://grahamrpugh.com/2023/05/14/macaduk-presentation-eraseinstall.html
Apache License 2.0
837 stars 131 forks source link

Sparseimage not deleted when using the --move option #297

Closed andyincali closed 1 year ago

andyincali commented 1 year ago

The downloaded sparseimage is not deleted when using the --move option.

This seems to be because find_existing_installer is run before the download, and thus the $existing_sparseimage variable is empty when the rm is run as a part of move_to_applications_folder().

It should be possible to populate $existing_sparseimage by adding this just below the existing_installer stuff on line 1097:

existing_sparseimage=$( find "$workdir/"*.sparseimage -maxdepth 1 -type f -print -quit 2>/dev/null )

grahampugh commented 1 year ago

Ah, I understand the problem. existing_sparseimage only applies when the script is run and a sparseimage is found already. If the sparseimage is freshly downloaded and --move is invoked, we only have downloaded_sparseimage. Yeah, should be able to fix that.

grahampugh commented 1 year ago

Should hopefully be fixed in the latest v27.0 upload.