diff --git a/actions/backups b/actions/backups index 7c3a9ac5b..cb539e7c0 100755 --- a/actions/backups +++ b/actions/backups @@ -27,6 +27,7 @@ import subprocess import sys import tarfile +from plinth.errors import ActionError from plinth.modules.backups import MANIFESTS_FOLDER, REPOSITORY @@ -174,10 +175,24 @@ def subcommand_get_archive_apps(arguments): manifest_path) manifest = json.loads(manifest_data) if manifest: - for app in manifest: + for app in _get_apps_of_manifest(manifest): print(app['name']) +def _get_apps_of_manifest(manifest): + """ + Get apps of a manifest. + Supports both dict format as well as list format of plinth <=0.42 + """ + if type(manifest) is list: + apps = manifest + elif type(manifest) is dict and 'apps' in manifest: + apps = manifest['apps'] + else: + raise ActionError('Unknown manifest format') + return apps + + def subcommand_get_exported_archive_apps(arguments): """Get list of apps included in an exported archive file.""" manifest = None @@ -191,7 +206,7 @@ def subcommand_get_exported_archive_apps(arguments): break if manifest: - for app in manifest: + for app in _get_apps_of_manifest(manifest): print(app['name']) diff --git a/plinth/modules/backups/__init__.py b/plinth/modules/backups/__init__.py index d56a77954..5f5095bc2 100644 --- a/plinth/modules/backups/__init__.py +++ b/plinth/modules/backups/__init__.py @@ -84,11 +84,13 @@ def _backup_handler(packet): manifest_path = os.path.join(MANIFESTS_FOLDER, get_valid_filename(packet.label) + '.json') - manifests = [{ - 'name': app.name, - 'version': app.app.version, - 'backup': app.manifest - } for app in packet.apps] + manifests = { + 'apps': [{ + 'name': app.name, + 'version': app.app.version, + 'backup': app.manifest + } for app in packet.apps] + } with open(manifest_path, 'w') as manifest_file: json.dump(manifests, manifest_file)