feat: add library cleanup screen and 'fix ignored files' window (#1070)

* feat(ui): add LibraryInfoWindow with statistics

* feat: add library cleanup screen

* fix: missing resource

* tests: add basic test for resource_manager.py

* feat: remove ignored files in bulk

* feat: open backups folder from library info window

* refactor: rename unlinked+ignored modal files

* refactor: sort en.json
This commit is contained in:
Travis Abendshien
2025-08-31 16:53:56 -07:00
committed by GitHub
parent 7a7e1cc4bd
commit 2f4b72fd4d
45 changed files with 1224 additions and 461 deletions

View File

@@ -9,8 +9,8 @@ import pytest
from tagstudio.core.library.alchemy.enums import BrowsingState
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.utils.missing_files import MissingRegistry
from tagstudio.core.utils.types import unwrap
from tagstudio.core.utils.unlinked_registry import UnlinkedRegistry
CWD = Path(__file__).parent
@@ -18,16 +18,16 @@ CWD = Path(__file__).parent
# NOTE: Does this test actually work?
@pytest.mark.parametrize("library", [TemporaryDirectory()], indirect=True)
def test_refresh_missing_files(library: Library):
registry = MissingRegistry(library=library)
registry = UnlinkedRegistry(lib=library)
# touch the file `one/two/bar.md` but in wrong location to simulate a moved file
(unwrap(library.library_dir) / "bar.md").touch()
# no files actually exist, so it should return all entries
assert list(registry.refresh_missing_files()) == [0, 1]
assert list(registry.refresh_unlinked_files()) == [0, 1]
# neither of the library entries exist
assert len(registry.missing_file_entries) == 2
assert len(registry.unlinked_entries) == 2
# iterate through two files
assert list(registry.fix_unlinked_entries()) == [0, 1]

View File

@@ -0,0 +1,19 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import structlog
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.resource_manager import ResourceManager
logger = structlog.get_logger()
def test_get():
rm = ResourceManager()
for res in rm._map: # pyright: ignore[reportPrivateUsage]
assert rm.get(res), f"Could not get resource '{res}'"
assert unwrap(rm.get_path(res)).exists(), f"Filepath for resource '{res}' does not exist"

View File

@@ -9,6 +9,9 @@ from pathlib import Path
import pytest
from tagstudio.core.constants import TS_FOLDER_NAME
from tagstudio.core.library.alchemy.constants import (
SQL_FILENAME,
)
from tagstudio.core.library.alchemy.library import Library
CWD = Path(__file__)
@@ -36,8 +39,8 @@ def test_library_migrations(path: str):
temp_path_ts = temp_path / TS_FOLDER_NAME
temp_path_ts.mkdir(exist_ok=True)
shutil.copy(
original_path / TS_FOLDER_NAME / Library.SQL_FILENAME,
temp_path / TS_FOLDER_NAME / Library.SQL_FILENAME,
original_path / TS_FOLDER_NAME / SQL_FILENAME,
temp_path / TS_FOLDER_NAME / SQL_FILENAME,
)
try: