diff --git a/src-node/installer/launch-windows-installer.js b/src-node/installer/launch-windows-installer.js index 75b235f679..2d97cd5aa7 100644 --- a/src-node/installer/launch-windows-installer.js +++ b/src-node/installer/launch-windows-installer.js @@ -1,51 +1,30 @@ const fs = require('fs'); const path = require('path'); -const { exec } = require('child_process'); +const { spawn } = require('child_process'); const args = process.argv.slice(2); // Skip the first two elements const appdataDir = args[0]; -function launchInstaller(zipFilePath, absoluteExtractPath) { - return new Promise((resolve, reject)=>{ - const extractPath = path.join(appdataDir, 'installer', "extracted"); - const dirContents = fs.readdirSync(extractPath); - console.log("extracted dir contents: ", dirContents); - let exePath; - if(dirContents.length === 1){ - exePath = path.join(extractPath, dirContents[0]); - if(!exePath.endsWith(".exe")){ - reject("Cannot resolve upgrade installer exe in: ", extractPath); - return; - } - } else { - reject("Cannot resolve upgrade installer exe in: ", extractPath); - return; - } - - exec(`"${exePath}" /P`, (error, stdout, stderr) => { - if (error) { - console.error(`Error extracting ZIP file: ${error.message}`); - reject(error.message); - return; - } - if (stderr) { - console.error(`Error output: ${stderr}`); - reject(stderr); - return; - } - console.log(`Updater launched successfully to ${absoluteExtractPath}`); - resolve(); - }); - }); -} if(!appdataDir) { process.exit(1); } -launchInstaller() - .then(()=>{ - process.exit(0); - }) - .catch((err)=>{ - console.error(err); +const extractPath = path.join(appdataDir, 'installer', "extracted"); +const dirContents = fs.readdirSync(extractPath); +console.log("extracted dir contents: ", dirContents); +let exePath; +if(dirContents.length === 1){ + exePath = path.join(extractPath, dirContents[0]); + if(!exePath.endsWith(".exe")){ + console.error("Cannot resolve upgrade installer exe in: ", extractPath); process.exit(1); - }); + } +} else { + console.error("Cannot resolve upgrade installer exe in: ", extractPath); + process.exit(1); +} +const child = spawn(`${exePath}`, ['/P'], { + detached: true, // This allows the child process to run independently of its parent. + stdio: 'ignore' // This is often used in conjunction with detached to avoid keeping the parent's stdio open. +}); +child.unref(); +process.exit(0); diff --git a/src/extensionsIntegrated/appUpdater/main.js b/src/extensionsIntegrated/appUpdater/main.js index 0e4b2cd7fc..a20ac057b4 100644 --- a/src/extensionsIntegrated/appUpdater/main.js +++ b/src/extensionsIntegrated/appUpdater/main.js @@ -62,6 +62,7 @@ define(function (require, exports, module) { } } }); + updateTask.show(); } let updateAvailable = PreferencesManager.getViewState(KEY_UPDATE_AVAILABLE); if(updateAvailable){ @@ -480,13 +481,9 @@ define(function (require, exports, module) { _refreshUpdateStatus(); // check for updates at boot let lastUpdateCheckTime = PreferencesManager.getViewState(KEY_LAST_UPDATE_CHECK_TIME); - if(!lastUpdateCheckTime){ - lastUpdateCheckTime = Date.now(); - PreferencesManager.setViewState(KEY_LAST_UPDATE_CHECK_TIME, lastUpdateCheckTime); - } const currentTime = Date.now(); const oneDayInMilliseconds = 24 * 60 * 60 * 1000; // 24 hours * 60 minutes * 60 seconds * 1000 milliseconds - if ((currentTime - lastUpdateCheckTime) < oneDayInMilliseconds) { + if(lastUpdateCheckTime && ((currentTime - lastUpdateCheckTime) < oneDayInMilliseconds)){ console.log("Skipping update check: last update check was within one day"); return; } diff --git a/src/features/TaskManager.js b/src/features/TaskManager.js index 7dba88fcc5..281dfd96d5 100644 --- a/src/features/TaskManager.js +++ b/src/features/TaskManager.js @@ -306,6 +306,7 @@ define(function (require, exports, module) { * @typedef {Object} TaskObject * Methods for managing the task's state and UI representation in the TaskManager. * + * @property {function(): void} show - Shows the task popup in the ui. * @property {function(): void} close - Closes the task and removes it from the UI. * @property {function(string): void} setTitle - Sets the task's title. * @property {function(): string} getTitle - Returns the task's title. @@ -432,6 +433,10 @@ define(function (require, exports, module) { return task._message; } + function show() { + $("#status-tasks .btn-dropdown").click(); + } + function setProgressPercent(percent) { task._percent = percent; task._completedStatus = STATUS_INCOMPLETE; @@ -495,6 +500,7 @@ define(function (require, exports, module) { _renderPlayIcons(task); } + task.show = show; task.close = close; task.setTitle = setTitle; task.getTitle = getTitle; @@ -539,7 +545,7 @@ define(function (require, exports, module) { exports._onSelect = _onSelect; exports._setLegacyExtensionBusy = _setLegacyExtensionBusy; - window.TaskManager = exports; // todo remove this + window.TaskManager = exports; // public apis exports.addNewTask = addNewTask; });