fix: remove preferences table (#1298)

* refactor: cleanup parameters of open_library and open_sqlite_library

* doc: notes on what tables are affected by which migration steps

* refactor(migration order): move DBv6 repairs

* refactor(migration order): move DBv8 repairs

* refactor(migration order): move DBv9 repairs

* refactor(migration order): move DBv100 repairs

* refactor(migration order): move DBv102 repairs

* refactor: merge migration methods

* doc: final comment changes

* fix: query tag ids independent of future DB changes

* feat: remove preferences table

* refactor: various references to LibraryPrefs

* fix: update josn migration UI

* refactor: remove last vestiges of preferences table

* fix: remove newly unnecessary translations

* doc: document library format changes

* refactor: merge the two methods used for migration 104

* fix: typo in sql statement

* fix: add back support for preferences table in get_version

* fix: properly remove directory in test

* fix: incorrect schema check in get_version

* fix: update search lib via migration

* fix: update assert in test

* fix: ignore element order in assert in test

* fix: use correct path

* fix: better test output

---------

Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
This commit is contained in:
Jann Stute
2026-05-09 05:16:22 +02:00
committed by GitHub
parent 96fc5ef065
commit ad2cbbca48
31 changed files with 109 additions and 276 deletions

View File

@@ -7,7 +7,7 @@ from tempfile import TemporaryDirectory
import pytest
from tagstudio.core.enums import LibraryPrefs
from tagstudio.core.constants import IGNORE_NAME
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.refresh import RefreshTracker
from tagstudio.core.utils.types import unwrap
@@ -20,15 +20,14 @@ CWD = Path(__file__).parent
def test_refresh_new_files(library: Library, exclude_mode: bool):
library_dir = unwrap(library.library_dir)
# Given
library.set_prefs(LibraryPrefs.IS_EXCLUDE_LIST, exclude_mode)
library.set_prefs(LibraryPrefs.EXTENSION_LIST, [".md"])
registry = RefreshTracker(library=library)
library.included_files.clear()
(library_dir / "FOO.MD").touch()
(library_dir / IGNORE_NAME).write_text("*.md" if exclude_mode else "*\n!*.md")
# Test if the single file was added
list(registry.refresh_dir(library_dir, force_internal_tools=True))
assert registry.files_not_in_library == [Path("FOO.MD")]
assert set(registry.files_not_in_library) == set([Path(IGNORE_NAME), Path("FOO.MD")])
@pytest.mark.parametrize("library", [TemporaryDirectory()], indirect=True)

View File

@@ -46,9 +46,9 @@ def test_library_migrations(path: str):
try:
status = library.open_library(library_dir=temp_path)
library.close()
shutil.rmtree(temp_path)
assert status.success
except Exception as e:
library.close()
shutil.rmtree(temp_path)
raise (e)
finally:
shutil.rmtree(temp_path)

View File

@@ -6,7 +6,6 @@
from pathlib import Path
from time import time
from tagstudio.core.enums import LibraryPrefs
from tagstudio.qt.mixed.migration_modal import JsonMigrationModal
CWD = Path(__file__)
@@ -43,10 +42,4 @@ def test_json_migration():
assert modal.check_color_parity()
# Extension Filter List ====================================================
# Count
assert len(modal.json_lib.ext_list) == len(modal.sql_lib.prefs(LibraryPrefs.EXTENSION_LIST))
# List Type
assert modal.check_ext_type()
# No Leading Dot
for ext in modal.sql_lib.prefs(LibraryPrefs.EXTENSION_LIST): # pyright: ignore[reportUnknownVariableType]
assert ext[0] != "."
modal.assert_ignore_parity()

View File

@@ -10,7 +10,6 @@ from tempfile import TemporaryDirectory
import pytest
import structlog
from tagstudio.core.enums import DefaultEnum, LibraryPrefs
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.library.alchemy.fields import (
FieldID, # pyright: ignore[reportPrivateUsage]
@@ -199,11 +198,6 @@ def test_search_library_case_insensitive(library: Library):
assert results[0] == entry.id
def test_preferences(library: Library):
for pref in LibraryPrefs:
assert library.prefs(pref) == pref.default
def test_remove_entry_field(library: Library, entry_full: Entry):
title_field = entry_full.text_fields[0]
@@ -393,24 +387,6 @@ def test_update_field_order(library: Library, entry_full: Entry):
assert entry.text_fields[1].value == "second"
def test_library_prefs_multiple_identical_vals():
# check the preferences are inherited from DefaultEnum
assert issubclass(LibraryPrefs, DefaultEnum)
# create custom settings with identical values
class TestPrefs(DefaultEnum):
FOO = 1
BAR = 1
assert TestPrefs.FOO.default == 1
assert TestPrefs.BAR.default == 1
assert TestPrefs.BAR.name == "BAR"
# accessing .value should raise exception
with pytest.raises(AttributeError):
assert TestPrefs.BAR.value
def test_path_search_ilike(library: Library):
results = library.search_library(BrowsingState.from_path("bar.md"), page_size=500)
assert results.total_count == 1