| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.BaseUpdater = void 0;
- function _bluebirdLst() {
- const data = require("bluebird-lst");
- _bluebirdLst = function () {
- return data;
- };
- return data;
- }
- function _AppUpdater() {
- const data = require("./AppUpdater");
- _AppUpdater = function () {
- return data;
- };
- return data;
- }
- class BaseUpdater extends _AppUpdater().AppUpdater {
- constructor(options, app) {
- super(options, app);
- this.quitAndInstallCalled = false;
- this.quitHandlerAdded = false;
- }
- quitAndInstall(isSilent = false, isForceRunAfter = false) {
- var _this = this;
- return (0, _bluebirdLst().coroutine)(function* () {
- _this._logger.info(`Install on explicit quitAndInstall`);
- const isInstalled = yield _this.install(isSilent, isSilent ? isForceRunAfter : true);
- if (isInstalled) {
- setImmediate(() => {
- if (_this.app.quit !== undefined) {
- _this.app.quit();
- }
- });
- } else {
- _this.quitAndInstallCalled = false;
- }
- })();
- }
- executeDownload(taskOptions) {
- var _this2 = this;
- return super.executeDownload(Object.assign({}, taskOptions, {
- done: (() => {
- var _ref = (0, _bluebirdLst().coroutine)(function* () {
- _this2.addQuitHandler();
- });
- return function done() {
- return _ref.apply(this, arguments);
- };
- })()
- }));
- }
- install(isSilent, isRunAfter) {
- var _this3 = this;
- return (0, _bluebirdLst().coroutine)(function* () {
- if (_this3.quitAndInstallCalled) {
- _this3._logger.warn("install call ignored: quitAndInstallCalled is set to true");
- return false;
- }
- const installerPath = _this3.downloadedUpdateHelper.file; // todo check (for now it is ok to no check as before, cached (from previous launch) update file checked in any case)
- // const isValid = await this.isUpdateValid(installerPath)
- if (installerPath == null) {
- _this3.dispatchError(new Error("No valid update available, can't quit and install"));
- return false;
- } // prevent calling several times
- _this3.quitAndInstallCalled = true;
- try {
- _this3._logger.info(`Install: isSilent: ${isSilent}, isRunAfter: ${isRunAfter}`);
- return _this3.doInstall(installerPath, isSilent, isRunAfter);
- } catch (e) {
- _this3.dispatchError(e);
- return false;
- }
- })();
- }
- addQuitHandler() {
- var _this4 = this;
- if (this.quitHandlerAdded || !this.autoInstallOnAppQuit) {
- return;
- }
- this.quitHandlerAdded = true;
- this.app.once("quit", (0, _bluebirdLst().coroutine)(function* () {
- if (!_this4.quitAndInstallCalled) {
- _this4._logger.info("Auto install update on quit");
- yield _this4.install(true, false);
- } else {
- _this4._logger.info("Update installer has already been triggered. Quitting application.");
- }
- }));
- }
- } exports.BaseUpdater = BaseUpdater;
- //# sourceMappingURL=BaseUpdater.js.map
|