From bf786742a5924c7b9ee0565b5deb027b25bf35ac Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Wed, 25 Mar 2026 07:17:28 +1100 Subject: [PATCH] feat: enhance update installation process for Linux, Windows, and macOS --- electron/main.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/electron/main.js b/electron/main.js index 2681c97..6f2bba8 100644 --- a/electron/main.js +++ b/electron/main.js @@ -257,18 +257,44 @@ async function downloadGiteaUpdate() { /** * Launches the downloaded installer (or opens the release page if no file was * downloaded) and quits the app. + * On Linux/AppImage: overwrites the running AppImage in-place and relaunches. + * On Windows: runs the installer and quits. + * On macOS: opens the DMG for manual installation. */ function installGiteaUpdate() { if (downloadedUpdatePath && fs.existsSync(downloadedUpdatePath)) { if (process.platform === 'win32') { exec(`"${downloadedUpdatePath}"`); + app.quit(); + } else if (process.platform === 'linux') { + const currentAppImage = process.env.APPIMAGE; + if (currentAppImage) { + try { + fs.chmodSync(downloadedUpdatePath, 0o755); + fs.copyFileSync(downloadedUpdatePath, currentAppImage); + fs.unlinkSync(downloadedUpdatePath); + console.log('AppImage replaced, relaunching...'); + app.relaunch({ execPath: currentAppImage }); + app.quit(); + } catch (err) { + console.error('Failed to replace AppImage in-place, opening file instead:', err); + shell.openPath(downloadedUpdatePath); + app.quit(); + } + } else { + // Not running as AppImage (e.g. dev/unpacked), just open it + shell.openPath(downloadedUpdatePath); + app.quit(); + } } else { + // macOS: open the DMG for manual installation shell.openPath(downloadedUpdatePath); + app.quit(); } } else if (pendingUpdateInfo?.htmlUrl) { shell.openExternal(pendingUpdateInfo.htmlUrl); + app.quit(); } - app.quit(); }