From d4f0597e9b7baf0683e5bf5d584ec141899b7ae6 Mon Sep 17 00:00:00 2001 From: yedpodtrzitko Date: Wed, 11 Sep 2024 13:31:22 +0700 Subject: [PATCH] undo the extension check in refresh_dir --- tagstudio/src/core/utils/refresh_dir.py | 19 +------------------ tagstudio/tests/macros/test_refresh_dir.py | 7 +------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/tagstudio/src/core/utils/refresh_dir.py b/tagstudio/src/core/utils/refresh_dir.py index 7e2224e3..3fb04fab 100644 --- a/tagstudio/src/core/utils/refresh_dir.py +++ b/tagstudio/src/core/utils/refresh_dir.py @@ -5,7 +5,7 @@ import structlog -from src.core.constants import TS_FOLDER_NAME, LibraryPrefs +from src.core.constants import TS_FOLDER_NAME from src.core.library import Library, Entry logger = structlog.get_logger(__name__) @@ -44,20 +44,6 @@ def refresh_dir(self, lib_path: Path) -> Iterator[int]: if self.library.library_dir is None: raise ValueError("No library directory set.") - is_exclude_list = self.library.prefs(LibraryPrefs.IS_EXCLUDE_LIST) - exclude_list = set(self.library.prefs(LibraryPrefs.EXTENSION_LIST)) - - def skip_suffix(suffix: str) -> bool: - """Determine if the file extension should be skipped. - - Declared as local function as it's faster. - - - check if the suffix is in the library's "exclude list" - - if library uses "exclude mode", and extensions is in the list, we skip - - if library uses "include mode", and extensions is not in the list, we skip - """ - return (suffix.lower() in exclude_list) == is_exclude_list - start_time_total = time() start_time_loop = time() @@ -72,9 +58,6 @@ def skip_suffix(suffix: str) -> bool: if "$RECYCLE.BIN" in str_path or TS_FOLDER_NAME in str_path: continue - if skip_suffix(path_item.suffix): - continue - dir_file_count += 1 relative_path = path_item.relative_to(lib_path) # TODO - load these in batch somehow diff --git a/tagstudio/tests/macros/test_refresh_dir.py b/tagstudio/tests/macros/test_refresh_dir.py index 8c4864ff..f5887cd9 100644 --- a/tagstudio/tests/macros/test_refresh_dir.py +++ b/tagstudio/tests/macros/test_refresh_dir.py @@ -22,9 +22,4 @@ def test_refresh_new_files(library, exclude_mode): assert not list(registry.refresh_dir(library.library_dir)) # Then - if exclude_mode: - # .md is in the list & is_exclude_list is True - should not be registered - assert not registry.files_not_in_library - else: - # .md is in the list & is_exclude_list is False - should be registered - assert registry.files_not_in_library == [pathlib.Path("FOO.MD")] + assert registry.files_not_in_library == [pathlib.Path("FOO.MD")]