feat: enhance update installation process for Linux, Windows, and macOS
This commit is contained in:
@@ -257,19 +257,45 @@ async function downloadGiteaUpdate() {
|
|||||||
/**
|
/**
|
||||||
* Launches the downloaded installer (or opens the release page if no file was
|
* Launches the downloaded installer (or opens the release page if no file was
|
||||||
* downloaded) and quits the app.
|
* 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() {
|
function installGiteaUpdate() {
|
||||||
if (downloadedUpdatePath && fs.existsSync(downloadedUpdatePath)) {
|
if (downloadedUpdatePath && fs.existsSync(downloadedUpdatePath)) {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
exec(`"${downloadedUpdatePath}"`);
|
exec(`"${downloadedUpdatePath}"`);
|
||||||
} else {
|
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);
|
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) {
|
} else if (pendingUpdateInfo?.htmlUrl) {
|
||||||
shell.openExternal(pendingUpdateInfo.htmlUrl);
|
shell.openExternal(pendingUpdateInfo.htmlUrl);
|
||||||
}
|
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Single instance lock
|
// Single instance lock
|
||||||
|
|||||||
Reference in New Issue
Block a user