kc9wwh/macOSUpgrade

Disk space check not including macOS installer

robotech99 opened this issue · 2 comments

Script checks disk space okay, checks installer size, and then is supposed to combine both to calculate free space. The final free space total does not include the installer size which causes the script to fail Disk Check.

Example: Big Sur installer already cached on Mac (12gb), Mac has 40gb free space, script should add 40gb+12gb=52gb and continue. Instead script reports only 40gb free space and fails disk check, displays requirements not met - has at least 48gb of free space.

It appears the issue is "du" command using 512 byte calculation. Instead of calculating the Big Sur installer as 12.4gb, it appears as 0.02gb. I changed line 337 and added a new line below to multiply the du output by 512.

    installerSize=$(/usr/bin/du -s "$installerPath" | /usr/bin/awk '{print $1}' | /usr/bin/xargs)
    installerSizeBytes=$(( installerSize * 512 ))

I'm reviewing function validate_free_space() now.
As @robotech99 pointed, installerSizeBytes sets small size. As I checked It is number in Kiro Byte. Anyway it is small and it is bug.

In addition to that, there is a problem with the logic of calculating free space.

Current version, it adds the installer size to free space of Volume. But In fact, It doesn't have to do that.

For saving user time, when there is NOT the installer it expected, It should SUBTRACT the size of the installer from the free space.