From 5b9bdd2a2aa296cd77d5ba16a4df534f5fa6edd2 Mon Sep 17 00:00:00 2001 From: Vxrtrauter <101264710+Vxrtrauter@users.noreply.github.com> Date: Sun, 8 Mar 2026 02:16:16 +0100 Subject: [PATCH] feat: update download process to use temporary installer path and improve silent installation --- installer.iss | 1 + src/core/interface/gui.py | 30 ++++++++++-------------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/installer.iss b/installer.iss index 60e6034..8d58c9e 100644 --- a/installer.iss +++ b/installer.iss @@ -68,3 +68,4 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de [Run] Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent +Filename: "{app}\{#MyAppExeName}"; Flags: nowait skipifnotsilent diff --git a/src/core/interface/gui.py b/src/core/interface/gui.py index 485d3b1..f8ebc80 100644 --- a/src/core/interface/gui.py +++ b/src/core/interface/gui.py @@ -153,8 +153,12 @@ def _find_install_path(): def download_update(latest_version): + import tempfile + import time + new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe" url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe" + installer_path = os.path.join(tempfile.gettempdir(), new_filename) progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0) progress.setWindowTitle("Updating") @@ -179,11 +183,11 @@ def download_update(latest_version): progress.setValue(int(downloaded * 100 / total)) QtWidgets.QApplication.processEvents() - with open(new_filename, "wb") as f: + with open(installer_path, "wb") as f: for chunk in chunks: f.write(chunk) - if not os.path.exists(new_filename): + if not os.path.exists(installer_path): progress.close() raise FileNotFoundError("Executable not found") @@ -191,24 +195,10 @@ def download_update(latest_version): progress.setValue(100) QtWidgets.QApplication.processEvents() - proc = subprocess.Popen([new_filename, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS", "/NORESTART"]) - while proc.poll() is None: - QtWidgets.QApplication.processEvents() - import time - time.sleep(0.1) - - progress.close() - - try: - os.remove(new_filename) - except OSError: - pass - - install_path = _find_install_path() - if not install_path: - raise FileNotFoundError("Could not find SoftwareManager install location in registry") - subprocess.Popen([os.path.join(install_path, "SoftwareManager.exe")]) - + # Launch installer and exit — the installer will close this process, + # install the update, and relaunch the app via its [Run] section. + subprocess.Popen([installer_path, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS"]) + time.sleep(1) sys.exit(0)