1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-01 02:27:16 +01:00

Fix auto-updater and comments

This commit is contained in:
Nayam Amarshe 2023-09-11 07:58:33 +05:30
parent 80f6de55c3
commit 2cb905d262
3 changed files with 34 additions and 36 deletions

View File

@ -0,0 +1,25 @@
import { MessageBoxOptions, dialog } from "electron";
import { autoUpdater } from "electron-updater";
import logit from "../utils/logit";
const autoUpdate = (event) => {
autoUpdater.autoInstallOnAppQuit = false;
const dialogOpts: MessageBoxOptions = {
type: "info",
buttons: ["Install update", "No Thanks"],
title: "New Upscayl Update",
message: event.releaseName as string,
detail:
"A new version has been downloaded. Restart the application to apply the updates.",
};
logit("✅ Update Downloaded");
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
autoUpdater.quitAndInstall();
} else {
logit("🚫 Update Installation Cancelled");
}
});
};
export default autoUpdate;

View File

@ -1,14 +1,7 @@
import prepareNext from "electron-next";
import { autoUpdater } from "electron-updater";
import log from "electron-log";
import {
app,
ipcMain,
dialog,
MessageBoxOptions,
protocol,
net,
} from "electron";
import { app, ipcMain, protocol, net } from "electron";
import COMMAND from "./constants/commands";
import logit from "./utils/logit";
import openFolder from "./commands/open-folder";
@ -23,6 +16,7 @@ import electronIsDev from "electron-is-dev";
import { execPath, modelsPath } from "./utils/get-resource-paths";
import batchUpscayl from "./commands/batch-upscayl";
import doubleUpscayl from "./commands/double-upscayl";
import autoUpdate from "./commands/auto-update";
// INITIALIZATION
log.initialize({ preload: true });
@ -70,25 +64,4 @@ ipcMain.on(COMMAND.FOLDER_UPSCAYL, batchUpscayl);
ipcMain.on(COMMAND.DOUBLE_UPSCAYL, doubleUpscayl);
//------------------------Auto-Update Code-----------------------------//
autoUpdater.autoInstallOnAppQuit = false;
autoUpdater.on("update-downloaded", (event) => {
autoUpdater.autoInstallOnAppQuit = false;
const dialogOpts: MessageBoxOptions = {
type: "info",
buttons: ["Install update", "No Thanks"],
title: "New Upscayl Update",
message: event.releaseName as string,
detail:
"A new version has been downloaded. Restart the application to apply the updates.",
};
logit("✅ Update Downloaded");
dialog.showMessageBox(dialogOpts).then((returnValue) => {
if (returnValue.response === 0) {
autoUpdater.quitAndInstall();
} else {
logit("🚫 Update Installation Cancelled");
}
});
});
autoUpdater.on("update-downloaded", autoUpdate);

View File

@ -1,14 +1,14 @@
/*
appRootDir is the resources directory inside the unpacked electron app temp directory.
resources contains app.asar file, that contains the main and renderer files.
We're putting resources/{os}/bin from project inside resources/bin of electron. Same for the models directory as well.
*/
import { join, dirname, resolve } from "path";
import { getPlatform } from "./get-device-specs";
import isDev from "electron-is-dev";
import { app } from "electron";
/**
* appRootDir is the resources directory inside the unpacked electron app temp directory.
* resources contains app.asar file, that contains the main and renderer files.
* We're putting resources/{os}/bin from project inside resources/bin of electron.
* Same for the models directory as well.
*/
const appRootDir = app.getAppPath();
const binariesPath = isDev