From 4af2a537ef431918a5cf53b3ba18abe6b2d18c1e Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Thu, 21 Nov 2024 13:11:19 -0600 Subject: [PATCH] Prevent update downgrade from stable --- receivers/electron/forge.config.js | 8 ++++---- receivers/electron/src/Updater.ts | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/receivers/electron/forge.config.js b/receivers/electron/forge.config.js index af84960..064e1f2 100644 --- a/receivers/electron/forge.config.js +++ b/receivers/electron/forge.config.js @@ -110,7 +110,7 @@ module.exports = { const exePath = `./out/${APPLICATION_NAME}-${packageResults.platform}-${packageResults.arch}/${APPLICATION_NAME}.exe`; if (fs.existsSync(CI_SIGNING_DIR)) { - console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${exePath}`))); + console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${exePath}`)).toString().trim()); } else { console.warn('Windows signing script not found, skipping...'); @@ -163,7 +163,7 @@ module.exports = { fs.renameSync(`./out/make/wix/${e.arch}/${artifactName}`, artifactPath); if (fs.existsSync(CI_SIGNING_DIR)) { - console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${artifactPath}`))); + console.log(cp.execSync(path.join(CI_SIGNING_DIR, `sign.sh ${artifactPath}`)).toString().trim()); } else { console.warn('Windows signing script not found, skipping...'); @@ -182,8 +182,8 @@ module.exports = { console.log(`Making a zip distributable for ${e.platform}/${e.arch}`); const zipPath = path.resolve(process.cwd(), 'out', 'make', 'zip', e.platform, e.arch, generateArtifactName(e.packageJSON, e.platform, e.arch, 'zip')); - console.log(cp.execSync(`mkdir -p ${path.dirname(zipPath)}`)); - console.log(cp.execSync(`cd out/${APPLICATION_NAME}-${e.platform}-${e.arch}; zip -r -y "${zipPath}" "${APPLICATION_TITLE}.app"`)); + console.log(cp.execSync(`mkdir -p ${path.dirname(zipPath)}`).toString().trim()); + console.log(cp.execSync(`cd out/${APPLICATION_NAME}-${e.platform}-${e.arch}; zip -r -y "${zipPath}" "${APPLICATION_TITLE}.app"`).toString().trim()); break; } case "linux": { diff --git a/receivers/electron/src/Updater.ts b/receivers/electron/src/Updater.ts index acab06f..a8ba06a 100644 --- a/receivers/electron/src/Updater.ts +++ b/receivers/electron/src/Updater.ts @@ -326,7 +326,7 @@ export class Updater { const localChannelVersion: number = Updater.localPackageJson.channelVersion ? Updater.localPackageJson.channelVersion : 0; const currentChannelVersion: number = Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] ? Updater.releasesJson.channelCurrentVersions[Updater.updateChannel] : 0; logger.info('Update check', { - channel: Updater.updateChannel, + updateChannel: Updater.updateChannel, channel_version: localChannelVersion, localVersion: Updater.localPackageJson.version, currentVersion: Updater.releasesJson.currentVersion, @@ -340,7 +340,10 @@ export class Updater { // Allow for update promotion to stable, while still getting updates from the subscribed channel const newCommit = (Updater.updateChannel !== 'stable' && Updater.localPackageJson.commit !== Updater.releasesJson.currentCommit); - if (newVersion || newChannelVersion || newCommit) { + // Prevent downgrading to sub channel if on stable + const isDowngrade = Updater.releaseChannel === 'stable' && newChannelVersion; + + if ((newVersion || newChannelVersion || newCommit) && !isDowngrade) { logger.info('Update available...'); return true; }