From 8b8a8fb3c74f1632f315181d95cbdc9ef2a3512e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 2 Apr 2021 03:13:53 +0200 Subject: [PATCH] Drop support for restoring backup archives from prior to 3.8 --- locales/en.json | 1 + src/yunohost/backup.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/locales/en.json b/locales/en.json index 199c21b66..51fba7024 100644 --- a/locales/en.json +++ b/locales/en.json @@ -528,6 +528,7 @@ "restore_already_installed_app": "An app with the ID '{app:s}' is already installed", "restore_already_installed_apps": "The following apps can't be restored because they are already installed: {apps}", "restore_app_failed": "Could not restore {app:s}", + "restore_backup_too_old": "This backup archive can not be restored because it comes from a too-old YunoHost version.", "restore_cleaning_failed": "Could not clean up the temporary restoration directory", "restore_complete": "Restoration completed", "restore_confirm_yunohost_installed": "Do you really want to restore an already installed system? [{answers:s}]", diff --git a/src/yunohost/backup.py b/src/yunohost/backup.py index 93f532525..3ffb3a875 100644 --- a/src/yunohost/backup.py +++ b/src/yunohost/backup.py @@ -36,6 +36,7 @@ from datetime import datetime from glob import glob from collections import OrderedDict from functools import reduce +from packaging import version from moulinette import msignals, m18n, msettings from moulinette.utils import filesystem @@ -858,6 +859,9 @@ class RestoreManager: # FIXME this way to get the info is not compatible with copy or custom # backup methods self.info = backup_info(name, with_details=True) + if not self.info["from_yunohost_version"] or version.parse(self.info["from_yunohost_version"]) < version.parse("3.8.0"): + raise YunohostValidationError("restore_backup_too_old") + self.archive_path = self.info["path"] self.name = name self.method = BackupMethod.create(method, self) @@ -2530,6 +2534,7 @@ def backup_info(name, with_details=False, human_readable=False): result["apps"] = info["apps"] result["system"] = info[system_key] + result["from_yunohost_version"] = info.get("from_yunohost_version") return result