From 491a0ca24e2fa16955594928aff0b4a58b462ed8 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Tue, 12 Mar 2019 21:30:28 +0530 Subject: [PATCH 1/3] ELECTRON-1129 - Fix first time launch issue (#590) --- js/config.js | 11 +++++++---- js/main.js | 48 +++++++++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/js/config.js b/js/config.js index 483d8192..bb8e9311 100644 --- a/js/config.js +++ b/js/config.js @@ -265,6 +265,7 @@ function updateUserConfig(oldUserConfig) { reject(new Error(`Failed to update user config error: ${err}`)); return; } + userConfig = newUserConfig; resolve(); }); }); @@ -275,7 +276,7 @@ function updateUserConfig(oldUserConfig) { * Manipulates user config on first time launch * @returns {Promise} */ -function updateUserConfigOnLaunch() { +function updateUserConfigOnLaunch(resolve, reject) { // we get the user config path using electron const userConfigFile = path.join(app.getPath('userData'), configFileName); @@ -283,7 +284,7 @@ function updateUserConfigOnLaunch() { // user config file doesn't exist, we simple move on if (!fs.existsSync(userConfigFile)) { log.send(logLevels.WARN, 'config: Could not find the user config file!'); - return Promise.reject(new Error('config: Could not find the user config file!')); + return reject(new Error('config: Could not find the user config file!')); } // In case the file exists, we remove it so that all the @@ -294,9 +295,11 @@ function updateUserConfigOnLaunch() { const version = app.getVersion().toString() || '1.0.0'; const updatedData = Object.assign(data || {}, { configVersion: version }); - return updateUserConfig(updatedData); + updateUserConfig(updatedData) + .then(resolve) + .catch(reject); }).catch((err) => { - return Promise.reject(err); + return reject(err); }); } diff --git a/js/main.js b/js/main.js index 3cb711d0..63991bfa 100644 --- a/js/main.js +++ b/js/main.js @@ -313,24 +313,27 @@ function setupThenOpenMainWindow() { } function checkFirstTimeLaunch() { - return getUserConfigField('configVersion') - .then((configVersion) => { - const appVersionString = app.getVersion().toString(); - const execPath = nodePath.dirname(app.getPath('exe')); - const shouldUpdateUserConfig = execPath.indexOf('AppData\\Local\\Programs') !== -1 || isMac; + return new Promise((resolve, reject) => { + getUserConfigField('configVersion') + .then((configVersion) => { + const appVersionString = app.getVersion().toString(); + const execPath = nodePath.dirname(app.getPath('exe')); + const shouldUpdateUserConfig = execPath.indexOf('AppData\\Local\\Programs') !== -1 || isMac; - if (!(configVersion - && typeof configVersion === 'string' - && (compareSemVersions.check(appVersionString, configVersion) !== 1)) && shouldUpdateUserConfig) { - return setupFirstTimeLaunch(); - } - log.send(logLevels.INFO, `not a first-time launch as + if (!(configVersion + && typeof configVersion === 'string' + && (compareSemVersions.check(appVersionString, configVersion) !== 1))) { + return setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig); + } + log.send(logLevels.INFO, `not a first-time launch as configVersion: ${configVersion} appVersion: ${appVersionString} shouldUpdateUserConfig: ${shouldUpdateUserConfig}`); - return Promise.resolve(); - }) - .catch(() => { - return setupFirstTimeLaunch(); - }); + return resolve(); + }) + .catch((e) => { + log.send(logLevels.ERROR, `Error reading configVersion error: ${e}`); + return setupFirstTimeLaunch(resolve, reject, false); + }); + }); } /** @@ -339,11 +342,18 @@ function checkFirstTimeLaunch() { * * @return {Promise} */ -function setupFirstTimeLaunch() { +function setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig) { log.send(logLevels.INFO, 'setting first time launch config'); - return getConfigField('launchOnStartup') + getConfigField('launchOnStartup') .then(setStartup) - .then(updateUserConfigOnLaunch); + .then(() => { + if (shouldUpdateUserConfig) { + log.send(logLevels.INFO, `Resetting user config data? ${shouldUpdateUserConfig}`); + return updateUserConfigOnLaunch(resolve, reject); + } + return resolve(); + }) + .catch(reject); } /** From 71eb7961392b23c7e5bbfca49102799f865c00fe Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Wed, 13 Mar 2019 16:32:55 +0530 Subject: [PATCH 2/3] ELECTRON-1132 (Remove HKU registry entry on uninstalling the SDA) (#592) * ELECTRON-1132 - Remove HKU registry entry on uninstalling the SDA * ELECTRON-1132 - Change logic to use build number instead of version number to validate first time launch * ELECTRON-1132 - Remove config exits check as we gracefully create a new config file --- installer/win/Symphony-x64.aip | 2 +- installer/win/Symphony-x86.aip | 2 +- js/config.js | 17 +++++------------ js/main.js | 14 +++++--------- 4 files changed, 12 insertions(+), 23 deletions(-) diff --git a/installer/win/Symphony-x64.aip b/installer/win/Symphony-x64.aip index 65bf9d4f..c023785a 100644 --- a/installer/win/Symphony-x64.aip +++ b/installer/win/Symphony-x64.aip @@ -596,7 +596,7 @@ - + diff --git a/installer/win/Symphony-x86.aip b/installer/win/Symphony-x86.aip index 23026ec7..5878e5a9 100644 --- a/installer/win/Symphony-x86.aip +++ b/installer/win/Symphony-x86.aip @@ -578,7 +578,7 @@ - + diff --git a/js/config.js b/js/config.js index bb8e9311..d445ce41 100644 --- a/js/config.js +++ b/js/config.js @@ -13,6 +13,7 @@ const isMac = require('./utils/misc.js').isMac; const getRegistry = require('./utils/getRegistry.js'); const log = require('./log.js'); const logLevels = require('./enums/logLevels.js'); +const { buildNumber } = require('../package.json'); const configFileName = 'Symphony.config'; @@ -191,10 +192,10 @@ function updateConfigField(fieldName, newValue) { return saveUserConfig(fieldName, newValue, config); }, () => { // in case config doesn't exist, can't read or is corrupted. - // add configVersion - just in case in future we need to provide + // add configBuildNumber - just in case in future we need to provide // upgrade capabilities. return saveUserConfig(fieldName, newValue, { - configVersion: app.getVersion().toString(), + configBuildNumber: buildNumber || '0', }); }); } @@ -280,20 +281,12 @@ function updateUserConfigOnLaunch(resolve, reject) { // we get the user config path using electron const userConfigFile = path.join(app.getPath('userData'), configFileName); - // if it's not a per user installation or if the - // user config file doesn't exist, we simple move on - if (!fs.existsSync(userConfigFile)) { - log.send(logLevels.WARN, 'config: Could not find the user config file!'); - return reject(new Error('config: Could not find the user config file!')); - } - // In case the file exists, we remove it so that all the // values are fetched from the global config // https://perzoinc.atlassian.net/browse/ELECTRON-126 return readUserConfig(userConfigFile).then((data) => { - // Add version info to the user config data - const version = app.getVersion().toString() || '1.0.0'; - const updatedData = Object.assign(data || {}, { configVersion: version }); + // Add build number info to the user config data + const updatedData = Object.assign(data || {}, { configBuildNumber: buildNumber || '0' }); updateUserConfig(updatedData) .then(resolve) diff --git a/js/main.js b/js/main.js index 63991bfa..ebb8e269 100644 --- a/js/main.js +++ b/js/main.js @@ -24,7 +24,6 @@ const { setCheckboxValues } = require('./menus/menuTemplate.js'); const autoLaunch = require('./autoLaunch'); const { handleCacheFailureCheckOnStartup, handleCacheFailureCheckOnExit} = require('./cacheHandler'); -const compareSemVersions = require('./utils/compareSemVersions.js'); const { isMac, isDevEnv } = require('./utils/misc.js'); const getCmdLineArg = require('./utils/getCmdLineArg.js'); @@ -314,24 +313,21 @@ function setupThenOpenMainWindow() { function checkFirstTimeLaunch() { return new Promise((resolve, reject) => { - getUserConfigField('configVersion') - .then((configVersion) => { - const appVersionString = app.getVersion().toString(); + getUserConfigField('configBuildNumber') + .then((configBuildNumber) => { const execPath = nodePath.dirname(app.getPath('exe')); const shouldUpdateUserConfig = execPath.indexOf('AppData\\Local\\Programs') !== -1 || isMac; - if (!(configVersion - && typeof configVersion === 'string' - && (compareSemVersions.check(appVersionString, configVersion) !== 1))) { + if (configBuildNumber && typeof configBuildNumber === 'string' && configBuildNumber !== buildNumber) { return setupFirstTimeLaunch(resolve, reject, shouldUpdateUserConfig); } log.send(logLevels.INFO, `not a first-time launch as - configVersion: ${configVersion} appVersion: ${appVersionString} shouldUpdateUserConfig: ${shouldUpdateUserConfig}`); + configBuildNumber: ${configBuildNumber} installerBuildNumber: ${buildNumber} shouldUpdateUserConfig: ${shouldUpdateUserConfig}`); return resolve(); }) .catch((e) => { log.send(logLevels.ERROR, `Error reading configVersion error: ${e}`); - return setupFirstTimeLaunch(resolve, reject, false); + return setupFirstTimeLaunch(resolve, reject, true); }); }); } From 01628e453f328a5d8bccd9a5d42b5a6b8373eab1 Mon Sep 17 00:00:00 2001 From: VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS Date: Thu, 14 Mar 2019 13:55:07 -0300 Subject: [PATCH 3/3] ELECTRON-1131: changing extension from jpeg to png on windows (#593) --- js/screenSnippet/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/screenSnippet/index.js b/js/screenSnippet/index.js index 4e3441e1..2dde01ac 100644 --- a/js/screenSnippet/index.js +++ b/js/screenSnippet/index.js @@ -7,7 +7,7 @@ const fs = require('fs'); const os = require('os'); const path = require('path'); -const { isMac, isDevEnv } = require('../utils/misc.js'); +const { isMac, isDevEnv, isWindowsOS } = require('../utils/misc.js'); const log = require('../log.js'); const logLevels = require('../enums/logLevels.js'); const eventEmitter = require('.././eventEmitter'); @@ -41,7 +41,7 @@ class ScreenSnippet { log.send(logLevels.INFO, 'ScreenSnippet: starting screen capture'); - let tmpFilename = 'symphonyImage-' + Date.now() + '.jpg'; + let tmpFilename = (isWindowsOS) ? 'symphonyImage-' + Date.now() + '.png' : 'symphonyImage-' + Date.now() + '.jpg'; let tmpDir = os.tmpdir(); let outputFileName = path.join(tmpDir, tmpFilename); @@ -144,10 +144,11 @@ function readResult(outputFileName, resolve, reject, childProcessErr) { try { // convert binary data to base64 encoded string let output = Buffer.from(data).toString('base64'); - resolve({ - type: 'image/jpg;base64', + const resultOutput = { + type: isWindowsOS ? 'image/png;base64' : 'image/jpg;base64', data: output - }); + }; + resolve(resultOutput); } catch (error) { reject(createError(error)); } finally {