From 05766680f7ff8d00b938dad8917ca8617abec35c Mon Sep 17 00:00:00 2001 From: King Phyte Date: Mon, 29 Apr 2024 11:04:29 +0000 Subject: [PATCH] fix: restoring site breaks when checking backup version (#26186) * fix: restoring site breaks when checking backup version The `backup_version` variable exists if and only if the `if match` branch executes, but it is used in a condition in a scope where it may not exist. Changing the variable to `match` leads to correct behaviour. * fix: restoring site breaks when checking backup version Co-authored-by: Akhil Narang * fix: version check when restoring site should be done from `match` scope * chore: add a `return None` for better readability No functional difference, just easier to understand/read the code. Signed-off-by: Akhil Narang --------- Signed-off-by: Akhil Narang Co-authored-by: Akhil Narang --- frappe/installer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frappe/installer.py b/frappe/installer.py index 36221d9e68..4c5475a5a1 100644 --- a/frappe/installer.py +++ b/frappe/installer.py @@ -807,9 +807,8 @@ def get_old_backup_version(sql_file_path: str) -> Version | None: """ header = get_db_dump_header(sql_file_path).split("\n") if match := re.search(r"Frappe (\d+\.\d+\.\d+)", header[0]): - backup_version = match[1] - - return Version(backup_version) if backup_version else None + return Version(match[1]) + return None def get_backup_version(sql_file_path: str) -> Version | None: