disallow downgrade of App Store apps
We hit this interesting case: 1. Dashboard showed update indicator for an app of v1. indicator is saying v2 is available. 2. In the meantime, the cron updated the app from v1 to v2 and then to v3 (i.e updates applied) 3. Dashboard for whatever reason (internet issues/laptop suspend) continues to show v2 update indicator. This is despite the update logic clearing the update available notification. 4. Use clicked updated indicator on the updated app. App updates to an old version v2!
This commit is contained in:
20
src/apps.js
20
src/apps.js
@@ -818,6 +818,18 @@ function update(appId, data, auditSource, callback) {
|
||||
|
||||
updateConfig.manifest = manifest;
|
||||
|
||||
// prevent user from installing a app with different manifest id over an existing app
|
||||
// this allows cloudron install -f --app <appid> for an app installed from the appStore
|
||||
if (app.manifest.id !== updateConfig.manifest.id) {
|
||||
if (!data.force) return callback(new AppsError(AppsError.BAD_FIELD, 'manifest id does not match. force to override'));
|
||||
// clear appStoreId so that this app does not get updates anymore
|
||||
updateConfig.appStoreId = '';
|
||||
}
|
||||
|
||||
if (app.appStoreId !== '' && semver.lte(updateConfig.manifest.version, app.manifest.version)) {
|
||||
if (!data.force) return callback(new AppsError(AppsError.BAD_FIELD, 'Downgrades are not permitted for apps installed from AppStore. force to override'));
|
||||
}
|
||||
|
||||
if ('icon' in data) {
|
||||
if (data.icon) {
|
||||
if (!validator.isBase64(data.icon)) return callback(new AppsError(AppsError.BAD_FIELD, 'icon is not base64'));
|
||||
@@ -830,14 +842,6 @@ function update(appId, data, auditSource, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
// prevent user from installing a app with different manifest id over an existing app
|
||||
// this allows cloudron install -f --app <appid> for an app installed from the appStore
|
||||
if (app.manifest.id !== updateConfig.manifest.id) {
|
||||
if (!data.force) return callback(new AppsError(AppsError.BAD_FIELD, 'manifest id does not match. force to override'));
|
||||
// clear appStoreId so that this app does not get updates anymore
|
||||
updateConfig.appStoreId = '';
|
||||
}
|
||||
|
||||
// do not update apps in debug mode
|
||||
if (app.debugMode && !data.force) return callback(new AppsError(AppsError.BAD_STATE, 'debug mode enabled. force to override'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user