Add encryptionVersion to backups

this will identify the old style backups and warn user that a restore
doesn't work anymore
This commit is contained in:
Girish Ramakrishnan
2020-05-13 22:09:33 -07:00
parent 66fd713d12
commit f417a49b34
8 changed files with 66 additions and 8 deletions

View File

@@ -1480,7 +1480,8 @@ function restore(app, backupId, auditSource, callback) {
func(function (error, backupInfo) {
if (error) return callback(error);
if (!backupInfo.manifest) callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get restore manifest'));
if (!backupInfo.manifest) return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get restore manifest'));
if (backupInfo.encryptionVersion === 1) return callback(new BoxError(BoxError.BAD_FIELD, 'This encrypted backup was created with an older Cloudron version and has to be restored using the CLI tool'));
// re-validate because this new box version may not accept old configs
error = checkManifestConstraints(backupInfo.manifest);
@@ -1603,7 +1604,8 @@ function clone(app, data, user, auditSource, callback) {
backups.get(backupId, function (error, backupInfo) {
if (error) return callback(error);
if (!backupInfo.manifest) callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get restore config'));
if (!backupInfo.manifest) return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get restore config'));
if (backupInfo.encryptionVersion === 1) return callback(new BoxError(BoxError.BAD_FIELD, 'This encrypted backup was created with an older Cloudron version and cannot be cloned'));
const manifest = backupInfo.manifest, appStoreId = app.appStoreId;