Skip to content

Commit

Permalink
database.upgrade:get_db_version - fix version number not being JSON-p…
Browse files Browse the repository at this point in the history
…arsed
  • Loading branch information
MatteoCampinoti94 committed Nov 12, 2024
1 parent 51a7052 commit 4196e9e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions acacore/database/upgrade.py
Original file line number Diff line number Diff line change
@@ -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__
Expand All @@ -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


Expand Down

0 comments on commit 4196e9e

Please sign in to comment.