Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 20 additions & 41 deletions src-node/installer/launch-windows-installer.js
Original file line number Diff line number Diff line change
@@ -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);
7 changes: 2 additions & 5 deletions src/extensionsIntegrated/appUpdater/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ define(function (require, exports, module) {
}
}
});
updateTask.show();
}
let updateAvailable = PreferencesManager.getViewState(KEY_UPDATE_AVAILABLE);
if(updateAvailable){
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion src/features/TaskManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -495,6 +500,7 @@ define(function (require, exports, module) {
_renderPlayIcons(task);
}

task.show = show;
task.close = close;
task.setTitle = setTitle;
task.getTitle = getTitle;
Expand Down Expand Up @@ -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;
});