Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/tagstudio/core/utils/refresh_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,25 @@ class RefreshDirTracker:
def files_count(self) -> int:
return len(self.files_not_in_library)

def save_new_files(self):
def save_new_files(self) -> Iterator[int]:
"""Save the list of files that are not in the library."""
if self.files_not_in_library:
index = 0
while index < len(self.files_not_in_library):
yield index
end = min(len(self.files_not_in_library), index + 200)
entries = [
Entry(
path=entry_path,
folder=self.library.folder,
fields=[],
date_added=dt.now(),
)
for entry_path in self.files_not_in_library
for entry_path in self.files_not_in_library[index:end]
]
self.library.add_entries(entries)

index = end
self.files_not_in_library = []

yield

def refresh_dir(self, lib_path: Path) -> Iterator[int]:
"""Scan a directory for files, and add those relative filenames to internal variables."""
if self.library.library_dir is None:
Expand Down
2 changes: 1 addition & 1 deletion src/tagstudio/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def add_new_files_runnable(self, tracker: RefreshDirTracker):
pw.show()

iterator.value.connect(
lambda: (
lambda _count: (
pw.update_label(
Translations.format(
"entries.running.dialog.new_entries", total=f"{files_count:n}"
Expand Down