From e0af49f638ba55ba3e07bd93c80c921a952a818d Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 25 Jun 2025 18:17:22 +0200 Subject: [PATCH] appstore: automatic is not stableOnly --- src/appstore.js | 4 ++-- src/cron.js | 2 +- src/routes/apps.js | 2 +- src/routes/updater.js | 2 +- src/test/updatechecker-test.js | 26 +++++++++++++------------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/appstore.js b/src/appstore.js index b4910ccfe..2ef0c2982 100644 --- a/src/appstore.js +++ b/src/appstore.js @@ -139,7 +139,7 @@ async function getBoxUpdate(options) { const query = { accessToken: token, boxVersion: constants.VERSION, - automatic: options.automatic + stableOnly: options.stableOnly }; const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/boxupdate`) @@ -182,7 +182,7 @@ async function getAppUpdate(app, options) { boxVersion: constants.VERSION, appId: app.appStoreId, appVersion: app.manifest.version, - automatic: options.automatic + stableOnly: options.stableOnly }; const [error, response] = await safe(superagent.get(`${await getApiServerOrigin()}/api/v1/appupdate`) diff --git a/src/cron.js b/src/cron.js index e1f73dc25..2c44ba527 100644 --- a/src/cron.js +++ b/src/cron.js @@ -130,7 +130,7 @@ async function startJobs() { // this is run separately from the update itself so that the user can disable automatic updates but can still get a notification gJobs.updateCheckerJob = CronJob.from({ cronTime: `00 ${minute} 1,5,9,13,17,21,23 * * *`, - onTick: async () => await safe(updateChecker.checkForUpdates({ automatic: true }), { debug }), + onTick: async () => await safe(updateChecker.checkForUpdates({ stableOnly: true }), { debug }), start: true }); diff --git a/src/routes/apps.js b/src/routes/apps.js index ebaa9f8da..b6ac828e0 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -1049,7 +1049,7 @@ async function checkForUpdates(req, res, next) { // it can take a while sometimes to get all the app updates one by one req.clearTimeout(); - await updateChecker.checkForUpdates({ automatic: false }); // appId argument is ignored for the moment + await updateChecker.checkForUpdates({ stableOnly: false }); // appId argument is ignored for the moment next(new HttpSuccess(200, { update: updateChecker.getUpdateInfo() })); } diff --git a/src/routes/updater.js b/src/routes/updater.js index 111fb910d..61692f803 100644 --- a/src/routes/updater.js +++ b/src/routes/updater.js @@ -56,6 +56,6 @@ async function checkForUpdates(req, res, next) { // it can take a while sometimes to get all the app updates one by one req.clearTimeout(); - await updateChecker.checkForUpdates({ automatic: false }); + await updateChecker.checkForUpdates({ stableOnly: false }); next(new HttpSuccess(200, { update: updateChecker.getUpdateInfo() })); } diff --git a/src/test/updatechecker-test.js b/src/test/updatechecker-test.js index 10c0fc8bb..cc86d9272 100644 --- a/src/test/updatechecker-test.js +++ b/src/test/updatechecker-test.js @@ -36,10 +36,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/boxupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, stableOnly: false }) .reply(204, { } ); - await updatechecker.checkForUpdates({ automatic: false }); + await updatechecker.checkForUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo().box).to.not.be.ok(); expect(scope.isDone()).to.be.ok(); }); @@ -49,10 +49,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/boxupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, stableOnly: false }) .reply(200, { version: UPDATE_VERSION, changelog: [''], sourceTarballUrl: 'box.tar.gz', sourceTarballSigUrl: 'box.tar.gz.sig', boxVersionsUrl: 'box.versions', boxVersionsSigUrl: 'box.versions.sig', unstable: false } ); - await updatechecker.checkForUpdates({ automatic: false }); + await updatechecker.checkForUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo().box).to.be.ok(); expect(updatechecker.getUpdateInfo().box.version).to.be(UPDATE_VERSION); expect(updatechecker.getUpdateInfo().box.sourceTarballUrl).to.be('box.tar.gz'); @@ -64,10 +64,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/boxupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, stableOnly: false }) .reply(404, { version: '2.0.0-pre.0', changelog: [''], sourceTarballUrl: 'box-pre.tar.gz' } ); - await updatechecker.checkForUpdates({ automatic: false }); + await updatechecker.checkForUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo().box.version).to.be(UPDATE_VERSION); expect(updatechecker.getUpdateInfo().box.sourceTarballUrl).to.be('box.tar.gz'); expect(scope.isDone()).to.be.ok(); @@ -86,10 +86,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/appupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, stableOnly: false }) .reply(204, { } ); - await updatechecker._checkAppUpdates({ automatic: false }); + await updatechecker._checkAppUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo()).to.eql({}); expect(scope.isDone()).to.be.ok(); }); @@ -99,10 +99,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/appupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, stableOnly: false }) .reply(500, { update: { manifest: { version: '1.0.0', changelog: '* some changes' } } } ); - await updatechecker._checkAppUpdates({ automatic: false }); + await updatechecker._checkAppUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo()).to.eql({}); expect(scope.isDone()).to.be.ok(); }); @@ -112,10 +112,10 @@ describe('updatechecker', function () { const scope = nock(mockApiServerOrigin) .get('/api/v1/appupdate') - .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, automatic: false }) + .query({ boxVersion: constants.VERSION, accessToken: appstoreToken, appId: app.appStoreId, appVersion: app.manifest.version, stableOnly: false }) .reply(200, { manifest: { version: '2.0.0', changelog: '* some changes' } } ); - await updatechecker._checkAppUpdates({ automatic: false }); + await updatechecker._checkAppUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo()).to.eql({ 'appid': { manifest: { version: '2.0.0', changelog: '* some changes' }, unstable: false } }); expect(scope.isDone()).to.be.ok(); }); @@ -123,7 +123,7 @@ describe('updatechecker', function () { it('does not offer old version', async function () { nock.cleanAll(); - await updatechecker._checkAppUpdates({ automatic: false }); + await updatechecker._checkAppUpdates({ stableOnly: false }); expect(updatechecker.getUpdateInfo()).to.eql({ }); }); });