From 210666df5eef6320c090b6ec5655c77de29b81c1 Mon Sep 17 00:00:00 2001 From: Anindya Roy <104991338+gitofanindya@users.noreply.github.com> Date: Thu, 28 Nov 2024 00:49:37 +0530 Subject: [PATCH] Update base.py --- nxdrive/dao/base.py | 58 ++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/nxdrive/dao/base.py b/nxdrive/dao/base.py index c6155f0c80..8189ed326b 100644 --- a/nxdrive/dao/base.py +++ b/nxdrive/dao/base.py @@ -155,35 +155,35 @@ def save_backup(self) -> bool: sys.excepthook(*sys.exc_info()) return False - def get_schema_version(self, cursor: Cursor, db_exists: bool) -> int: - """ - Get the schema version stored in the database. - Will fetch the information from a PRAGMA or the old storage variable. - """ - print("====== insude get_schema_version") - res = cursor.execute("PRAGMA user_version").fetchone() - # print(f"====== PRGMA user_version: {res!r}") - version = int(res[0]) if res else 0 - print(f"====== version: {version!r}") - if version == 0 and db_exists: - # Backward compatibility - tables = [ - res[0] - for res in cursor.execute( - "select name from sqlite_master where type = 'table'" - ).fetchall() - ] - print(f"====== tables: {tables!r}") - if "Configuration" not in tables: - print("===== Configuration not in tables; returning version = 0") - return 0 - res = cursor.execute( - "SELECT value FROM Configuration WHERE name = ?", (SCHEMA_VERSION,) - ).fetchone() - # print(f"====== res: {res!r}") - version = int(res[0]) if res else -1 - print(f"====== returning version: {version!r}") - return version + def get_schema_version(self, cursor: Cursor, db_exists: bool) -> int: + """ + Get the schema version stored in the database. + Will fetch the information from a PRAGMA or the old storage variable. + """ + print("====== insude get_schema_version") + res = cursor.execute("PRAGMA user_version").fetchone() + # print(f"====== PRGMA user_version: {res!r}") + version = int(res[0]) if res else 0 + print(f"====== version: {version!r}") + if version == 0 and db_exists: + # Backward compatibility + tables = [ + res[0] + for res in cursor.execute( + "select name from sqlite_master where type = 'table'" + ).fetchall() + ] + print(f"====== tables: {tables!r}") + if "Configuration" not in tables: + print("===== Configuration not in tables; returning version = 0") + return 0 + res = cursor.execute( + "SELECT value FROM Configuration WHERE name = ?", (SCHEMA_VERSION,) + ).fetchone() + # print(f"====== res: {res!r}") + version = int(res[0]) if res else -1 + print(f"====== returning version: {version!r}") + return version def set_schema_version(self, cursor: Cursor, version: int) -> None: """