Drop support for restoring backup archives from prior to 3.8

This commit is contained in:
Alexandre Aubin 2021-04-02 03:13:53 +02:00
parent 30421954a4
commit 8b8a8fb3c7
2 changed files with 6 additions and 0 deletions

View file

@ -528,6 +528,7 @@
"restore_already_installed_app": "An app with the ID '{app:s}' is already installed", "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_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_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_cleaning_failed": "Could not clean up the temporary restoration directory",
"restore_complete": "Restoration completed", "restore_complete": "Restoration completed",
"restore_confirm_yunohost_installed": "Do you really want to restore an already installed system? [{answers:s}]", "restore_confirm_yunohost_installed": "Do you really want to restore an already installed system? [{answers:s}]",

View file

@ -36,6 +36,7 @@ from datetime import datetime
from glob import glob from glob import glob
from collections import OrderedDict from collections import OrderedDict
from functools import reduce from functools import reduce
from packaging import version
from moulinette import msignals, m18n, msettings from moulinette import msignals, m18n, msettings
from moulinette.utils import filesystem 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 # FIXME this way to get the info is not compatible with copy or custom
# backup methods # backup methods
self.info = backup_info(name, with_details=True) 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.archive_path = self.info["path"]
self.name = name self.name = name
self.method = BackupMethod.create(method, self) 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["apps"] = info["apps"]
result["system"] = info[system_key] result["system"] = info[system_key]
result["from_yunohost_version"] = info.get("from_yunohost_version")
return result return result