Skip to content

Commit c9d61b5

Browse files
committed
undo the extension check in refresh_dir
1 parent c71d63c commit c9d61b5

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

tagstudio/src/core/utils/refresh_dir.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import structlog
77

8-
from src.core.constants import TS_FOLDER_NAME, LibraryPrefs
8+
from src.core.constants import TS_FOLDER_NAME
99
from src.core.library import Library, Entry
1010

1111
logger = structlog.get_logger(__name__)
@@ -44,39 +44,22 @@ def refresh_dir(self, lib_path: Path) -> Iterator[int]:
4444
if self.library.library_dir is None:
4545
raise ValueError("No library directory set.")
4646

47-
is_exclude_list = self.library.prefs(LibraryPrefs.IS_EXCLUDE_LIST)
48-
exclude_list = set(self.library.prefs(LibraryPrefs.EXTENSION_LIST))
49-
50-
def skip_suffix(suffix: str) -> bool:
51-
"""Determine if the file extension should be skipped.
52-
53-
Declared as local function as it's faster.
54-
55-
- check if the suffix is in the library's "exclude list"
56-
- if library uses "exclude mode", and extensions is in the list, we skip
57-
- if library uses "include mode", and extensions is not in the list, we skip
58-
"""
59-
return (suffix.lower() in exclude_list) == is_exclude_list
60-
6147
start_time_total = time()
6248
start_time_loop = time()
6349

6450
self.files_not_in_library = []
6551
dir_file_count = 0
6652

67-
for path_item in lib_path.glob("**/*"):
68-
str_path = str(path_item)
69-
if path_item.is_dir():
53+
for path in lib_path.glob("**/*"):
54+
str_path = str(path)
55+
if path.is_dir():
7056
continue
7157

7258
if "$RECYCLE.BIN" in str_path or TS_FOLDER_NAME in str_path:
7359
continue
7460

75-
if skip_suffix(path_item.suffix):
76-
continue
77-
7861
dir_file_count += 1
79-
relative_path = path_item.relative_to(lib_path)
62+
relative_path = path.relative_to(lib_path)
8063
# TODO - load these in batch somehow
8164
if not self.library.has_path_entry(relative_path):
8265
self.files_not_in_library.append(relative_path)

tagstudio/tests/macros/test_refresh_dir.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,4 @@ def test_refresh_new_files(library, exclude_mode):
2222
assert not list(registry.refresh_dir(library.library_dir))
2323

2424
# Then
25-
if exclude_mode:
26-
# .md is in the list & is_exclude_list is True - should not be registered
27-
assert not registry.files_not_in_library
28-
else:
29-
# .md is in the list & is_exclude_list is False - should be registered
30-
assert registry.files_not_in_library == [pathlib.Path("FOO.MD")]
25+
assert registry.files_not_in_library == [pathlib.Path("FOO.MD")]

0 commit comments

Comments
 (0)