mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-19 13:50:00 +10:00
installer.py: Ensure tmp dir is destroyed on exit
This commit is contained in:
+1
-1
@@ -1872,7 +1872,6 @@ class wx_python_gui:
|
|||||||
self.pulse_alternative(self.progress_bar)
|
self.pulse_alternative(self.progress_bar)
|
||||||
wx.GetApp().Yield()
|
wx.GetApp().Yield()
|
||||||
|
|
||||||
self.progress_bar.SetValue(0)
|
|
||||||
if self.prepare_result is True:
|
if self.prepare_result is True:
|
||||||
self.progress_label.SetLabel("Bytes Written: 0")
|
self.progress_label.SetLabel("Bytes Written: 0")
|
||||||
self.progress_label.Centre(wx.HORIZONTAL)
|
self.progress_label.Centre(wx.HORIZONTAL)
|
||||||
@@ -1887,6 +1886,7 @@ class wx_python_gui:
|
|||||||
self.download_thread = threading.Thread(target=self.download_and_unzip_pkg)
|
self.download_thread = threading.Thread(target=self.download_and_unzip_pkg)
|
||||||
self.download_thread.start()
|
self.download_thread.start()
|
||||||
default_output = float(utilities.monitor_disk_output(disk))
|
default_output = float(utilities.monitor_disk_output(disk))
|
||||||
|
self.progress_bar.SetValue(0)
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
output = float(utilities.monitor_disk_output(disk))
|
output = float(utilities.monitor_disk_output(disk))
|
||||||
|
|||||||
@@ -332,6 +332,8 @@ def list_disk_to_format():
|
|||||||
})
|
})
|
||||||
return list_disks
|
return list_disks
|
||||||
|
|
||||||
|
# Create global tmp directory
|
||||||
|
tmp_dir = tempfile.TemporaryDirectory()
|
||||||
|
|
||||||
def generate_installer_creation_script(tmp_location, installer_path, disk):
|
def generate_installer_creation_script(tmp_location, installer_path, disk):
|
||||||
# Creates installer.sh to be piped to OCLP-Helper and run as admin
|
# Creates installer.sh to be piped to OCLP-Helper and run as admin
|
||||||
@@ -352,8 +354,13 @@ def generate_installer_creation_script(tmp_location, installer_path, disk):
|
|||||||
|
|
||||||
# Create a new tmp directory
|
# Create a new tmp directory
|
||||||
# Our current one is a disk image, thus CoW will not work
|
# Our current one is a disk image, thus CoW will not work
|
||||||
ia_tmp = tempfile.mkdtemp()
|
global tmp_dir
|
||||||
|
ia_tmp = tmp_dir.name
|
||||||
|
|
||||||
print(f"Creating temporary directory at {ia_tmp}")
|
print(f"Creating temporary directory at {ia_tmp}")
|
||||||
|
# Delete all files in tmp_dir
|
||||||
|
for file in Path(ia_tmp).glob("*"):
|
||||||
|
subprocess.run(["rm", "-rf", str(file)])
|
||||||
|
|
||||||
# Copy installer to tmp (use CoW to avoid extra disk writes)
|
# Copy installer to tmp (use CoW to avoid extra disk writes)
|
||||||
subprocess.run(["cp", "-cR", installer_path, ia_tmp])
|
subprocess.run(["cp", "-cR", installer_path, ia_tmp])
|
||||||
|
|||||||
Reference in New Issue
Block a user