Skip to content

Commit

Permalink
remove db_version check
Browse files Browse the repository at this point in the history
  • Loading branch information
yedpodtrzitko committed Oct 29, 2024
1 parent 12bec6e commit 7e3ef7d
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 44 deletions.
7 changes: 0 additions & 7 deletions tagstudio/src/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion tagstudio/src/core/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
34 changes: 0 additions & 34 deletions tagstudio/src/core/library/alchemy/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tagstudio/tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7e3ef7d

Please sign in to comment.