From 4196e9ef5071f8be46a2e4832ef74a00ddf17de2 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Tue, 12 Nov 2024 10:35:40 +0100 Subject: [PATCH] database.upgrade:get_db_version - fix version number not being JSON-parsed --- acacore/database/upgrade.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/acacore/database/upgrade.py b/acacore/database/upgrade.py index fce28d2..3a20e14 100644 --- a/acacore/database/upgrade.py +++ b/acacore/database/upgrade.py @@ -1,8 +1,10 @@ +from plistlib import loads from sqlite3 import Connection from sqlite3 import DatabaseError from sqlite3 import OperationalError from typing import Callable +from packaging.version import InvalidVersion from packaging.version import Version from acacore.__version__ import __version__ @@ -17,8 +19,8 @@ def get_db_version(conn: Connection) -> Version | None: try: cur = conn.execute("select VALUE from Metadata where KEY like 'version'").fetchone() - return Version(cur[0]) if cur else None - except OperationalError: + return Version(loads(cur[0])) if cur else None + except (OperationalError, ValueError, InvalidVersion): raise None