From 7e3ef7dfed419fa2ca292142f9105cc8a863a36b Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Tue, 29 Oct 2024 09:43:11 +0700 Subject: [PATCH] remove db_version check --- tagstudio/src/core/constants.py | 7 ---- tagstudio/src/core/enums.py | 1 - tagstudio/src/core/library/alchemy/library.py | 34 ------------------- tagstudio/src/qt/widgets/preview_panel.py | 1 - tagstudio/tests/test_library.py | 2 +- 5 files changed, 1 insertion(+), 44 deletions(-) diff --git a/tagstudio/src/core/constants.py b/tagstudio/src/core/constants.py index ac6394060..893219290 100644 --- a/tagstudio/src/core/constants.py +++ b/tagstudio/src/core/constants.py @@ -15,10 +15,3 @@ TAG_FAVORITE = 1 TAG_ARCHIVED = 0 - - -class LibraryPrefs(Enum): - IS_EXCLUDE_LIST = True - EXTENSION_LIST: list[str] = [".json", ".xmp", ".aae"] - PAGE_SIZE: int = 500 - DB_VERSION: int = 1 diff --git a/tagstudio/src/core/enums.py b/tagstudio/src/core/enums.py index fe518da33..1e2e10be4 100644 --- a/tagstudio/src/core/enums.py +++ b/tagstudio/src/core/enums.py @@ -59,5 +59,4 @@ class LibraryPrefs(DefaultEnum): IS_EXCLUDE_LIST = True EXTENSION_LIST: list[str] = [".json", ".xmp", ".aae"] PAGE_SIZE: int = 500 - DB_VERSION: int = 2 LIBRARY_NAME: str = "TS Library" diff --git a/tagstudio/src/core/library/alchemy/library.py b/tagstudio/src/core/library/alchemy/library.py index f553323e5..92f32b314 100644 --- a/tagstudio/src/core/library/alchemy/library.py +++ b/tagstudio/src/core/library/alchemy/library.py @@ -171,21 +171,6 @@ def open_library( # default tags may exist already session.rollback() - # dont check db version when creating new library - if not is_new: - db_version = session.scalar( - select(Preferences).where(Preferences.key == LibraryPrefs.DB_VERSION.name) - ) - - if not db_version: - return LibraryStatus( - success=False, - message=( - "Library version mismatch.\n" - f"Found: v0, expected: v{LibraryPrefs.DB_VERSION.default}" - ), - ) - for pref in LibraryPrefs: try: session.add(Preferences(key=pref.name, value=pref.default)) @@ -210,25 +195,6 @@ def open_library( logger.debug("ValueType already exists", field=field) session.rollback() - db_version = session.scalar( - select(Preferences).where(Preferences.key == LibraryPrefs.DB_VERSION.name) - ) - # if the db version is different, we cant proceed - if db_version.value != LibraryPrefs.DB_VERSION.default: - logger.error( - "DB version mismatch", - db_version=db_version.value, - expected=LibraryPrefs.DB_VERSION.default, - ) - # TODO - handle migration - return LibraryStatus( - success=False, - message=( - "Library version mismatch.\n" - f"Found: v{db_version.value}, expected: v{LibraryPrefs.DB_VERSION.default}" - ), - ) - """ # check if folder matching current path exists already self.folder = session.scalar(select(Folder).where(Folder.path == library_dir)) diff --git a/tagstudio/src/qt/widgets/preview_panel.py b/tagstudio/src/qt/widgets/preview_panel.py index e6d7ccab4..f01835b3f 100644 --- a/tagstudio/src/qt/widgets/preview_panel.py +++ b/tagstudio/src/qt/widgets/preview_panel.py @@ -30,7 +30,6 @@ QVBoxLayout, QWidget, ) -from src.core.constants import IMAGE_TYPES, RAW_IMAGE_TYPES, TS_FOLDER_NAME, VIDEO_TYPES from src.core.enums import SettingItems, Theme from src.core.library.alchemy.enums import FilterState from src.core.library.alchemy.fields import ( diff --git a/tagstudio/tests/test_library.py b/tagstudio/tests/test_library.py index 95bd67d29..edec67788 100644 --- a/tagstudio/tests/test_library.py +++ b/tagstudio/tests/test_library.py @@ -2,7 +2,7 @@ from tempfile import TemporaryDirectory import pytest -from src.core.enums import LibraryPrefs +from src.core.enums import DefaultEnum, LibraryPrefs from src.core.library.alchemy import Entry from src.core.library.alchemy.enums import FilterState from src.core.library.alchemy.fields import TextField, _FieldID