Installer: Check space before starting

This commit is contained in:
Mykola Grymalyuk
2022-08-18 17:21:07 -06:00
parent 08525de489
commit 0cb2ad1b20
4 changed files with 22 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
## 0.4.11
- Enable AppleMCEReporterDisabler whenever spoofing affected SMBIOS
- ie. iMacPro1,1, MacPro6,1 and MacPro7,1
- Verify host's disk space before downloading macOS Installers
## 0.4.10
- Resolve Nvidia Kepler support in macOS 12.5 Beta 3 and newer

View File

@@ -1511,6 +1511,14 @@ class wx_python_gui:
except ValueError:
pass
# Ensure we have space to both download and extract the installer
host_space = utilities.get_free_space()
needed_space = app_dict['Size'] * 2
if host_space < needed_space:
dlg = wx.MessageDialog(self.frame_modal, f"You do not have enough free space to download and extract this installer. Please free up some space and try again\n\n{utilities.human_fmt(host_space)} available vs {utilities.human_fmt(needed_space)} required", "Insufficient Space", wx.OK | wx.ICON_WARNING)
dlg.ShowModal()
return
self.frame.DestroyChildren()
installer_name = f"macOS {app_dict['Version']} ({app_dict['Build']})"

View File

@@ -372,6 +372,13 @@ def generate_installer_creation_script(tmp_location, installer_path, disk):
if utilities.check_filesystem_type() != "apfs":
# HFS+ disks do not support CoW
args[1] = "-R"
# Ensure we have enough space for the duplication
space_available = utilities.get_free_space()
space_needed = Path(ia_tmp).stat().st_size
if space_available < space_needed:
print("Not enough free space to create installer.sh")
print(f"{utilities.human_fmt(space_available)} available, {utilities.human_fmt(space_needed)} required")
return False
subprocess.run(args)
# Adjust installer_path to point to the copied installer

View File

@@ -13,6 +13,7 @@ from ctypes import CDLL, c_uint, byref
import time
import atexit
import requests
import shutil
from resources import constants, ioreg
from data import sip_data, os_data
@@ -549,6 +550,11 @@ def find_disk_off_uuid(uuid):
pass
return None
def get_free_space(disk=None):
if disk is None:
disk = "/"
total, used, free = shutil.disk_usage("/")
return free
def grab_mount_point_from_disk(disk):
data = plistlib.loads(subprocess.run(f"diskutil info -plist {disk}".split(), stdout=subprocess.PIPE).stdout.decode().strip().encode())