mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
version properly comparated
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
import log from 'electron-log';
|
||||
import { UtilsService } from './utils.service';
|
||||
import { gt } from 'semver';
|
||||
export class AutoUpdaterService {
|
||||
|
||||
private static instance: AutoUpdaterService;
|
||||
@@ -24,7 +25,7 @@ export class AutoUpdaterService {
|
||||
autoUpdater.checkForUpdates().then(info => {
|
||||
const needUpdate = (() => {
|
||||
if(!info || !info.updateInfo){ return false; }
|
||||
if(autoUpdater.currentVersion.version === info.updateInfo.version){ return false; }
|
||||
if(gt(autoUpdater.currentVersion.version, info.updateInfo.version)){ return false; }
|
||||
return true;
|
||||
})();
|
||||
resolve(needUpdate)}
|
||||
@@ -38,10 +39,6 @@ export class AutoUpdaterService {
|
||||
autoUpdater.addListener("download-progress", info => {
|
||||
this.utilsService.ipcSend("update-download-progress", {success: true, data: info.percent});
|
||||
});
|
||||
// const promise = new Promise<boolean>((resolve, reject) => {
|
||||
// autoUpdater.addListener("update-downloaded", () => resolve(true));
|
||||
// autoUpdater.addListener("error", () => reject(false))
|
||||
// });
|
||||
|
||||
return autoUpdater.downloadUpdate().then(res => !!res && !!res.length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user