mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-04-24 20:10:14 +10:00
Implement getattrlist for improved CoW detection
This commit is contained in:
@@ -15,6 +15,7 @@ from pathlib import Path
|
||||
from .. import constants
|
||||
|
||||
from ..datasets import os_data
|
||||
from ..volume import generate_copy_arguments
|
||||
|
||||
from . import (
|
||||
network_handler,
|
||||
@@ -667,7 +668,7 @@ class KernelDebugKitUtilities:
|
||||
logging.info("Backup already exists, skipping")
|
||||
return
|
||||
|
||||
result = subprocess_wrapper.run_as_root(["/bin/cp", "-R", kdk_path, kdk_dst_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
result = subprocess_wrapper.run_as_root(generate_copy_arguments(kdk_path, kdk_dst_path), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
if result.returncode != 0:
|
||||
logging.info("Failed to create KDK backup:")
|
||||
subprocess_wrapper.log(result)
|
||||
@@ -16,6 +16,11 @@ from . import (
|
||||
subprocess_wrapper
|
||||
)
|
||||
|
||||
from ..volume import (
|
||||
can_copy_on_write,
|
||||
generate_copy_arguments
|
||||
)
|
||||
|
||||
|
||||
APPLICATION_SEARCH_PATH: str = "/Applications"
|
||||
SFR_SOFTWARE_UPDATE_PATH: str = "SFR/com_apple_MobileAsset_SFRSoftwareUpdate/com_apple_MobileAsset_SFRSoftwareUpdate.xml"
|
||||
@@ -90,13 +95,9 @@ class InstallerCreation():
|
||||
for file in Path(ia_tmp).glob("*"):
|
||||
subprocess.run(["/bin/rm", "-rf", str(file)])
|
||||
|
||||
# Copy installer to tmp (use CoW to avoid extra disk writes)
|
||||
args = ["/bin/cp", "-cR", installer_path, ia_tmp]
|
||||
if utilities.check_filesystem_type() != "apfs":
|
||||
# HFS+ disks do not support CoW
|
||||
args[1] = "-R"
|
||||
|
||||
# Ensure we have enough space for the duplication
|
||||
# Copy installer to tmp
|
||||
if can_copy_on_write(installer_path, ia_tmp) is False:
|
||||
# Ensure we have enough space for the duplication when CoW is not supported
|
||||
space_available = utilities.get_free_space()
|
||||
space_needed = Path(ia_tmp).stat().st_size
|
||||
if space_available < space_needed:
|
||||
@@ -104,7 +105,7 @@ class InstallerCreation():
|
||||
logging.info(f"{utilities.human_fmt(space_available)} available, {utilities.human_fmt(space_needed)} required")
|
||||
return False
|
||||
|
||||
subprocess.run(args)
|
||||
subprocess.run(generate_copy_arguments(installer_path, ia_tmp))
|
||||
|
||||
# Adjust installer_path to point to the copied installer
|
||||
installer_path = Path(ia_tmp) / Path(Path(installer_path).name)
|
||||
|
||||
Reference in New Issue
Block a user