Skip to content
Merged
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
2 changes: 1 addition & 1 deletion tagstudio/resources/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"entries.mirror.title": "Mirroring Entries",
"entries.mirror.window_title": "Mirror Entries",
"entries.mirror": "&Mirror",
"entries.running.dialog.new_entries": "Adding {count}/{total} New File Entries...",
"entries.running.dialog.new_entries": "Adding {total} New File Entries...",
"entries.running.dialog.title": "Adding New File Entries",
"entries.tags": "Tags",
"entries.unlinked.delete_alt": "De&lete Unlinked Entries",
Expand Down
28 changes: 13 additions & 15 deletions tagstudio/src/core/utils/refresh_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,23 @@ class RefreshDirTracker:
def files_count(self) -> int:
return len(self.files_not_in_library)

def save_new_files(self) -> Iterator[int]:
def save_new_files(self):
"""Save the list of files that are not in the library."""
if not self.files_not_in_library:
yield 0

for idx, entry_path in enumerate(self.files_not_in_library):
self.library.add_entries(
[
Entry(
path=entry_path,
folder=self.library.folder,
fields=[],
)
]
)
yield idx
if self.files_not_in_library:
entries = [
Entry(
path=entry_path,
folder=self.library.folder,
fields=[],
)
for entry_path in self.files_not_in_library
]
self.library.add_entries(entries)

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
13 changes: 6 additions & 7 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,8 @@ def add_new_files_callback(self):
"library.refresh.scanning.plural"
if x + 1 != 1
else "library.refresh.scanning.singular",
searched_count=x + 1,
found_count=tracker.files_count,
searched_count=f"{x+1:n}",
found_count=f"{tracker.files_count:n}",
)
),
)
Expand All @@ -813,20 +813,19 @@ def add_new_files_runnable(self, tracker: RefreshDirTracker):
pw = ProgressWidget(
cancel_button_text=None,
minimum=0,
maximum=files_count,
maximum=0,
)
Translations.translate_with_setter(pw.setWindowTitle, "entries.running.dialog.title")
Translations.translate_with_setter(
pw.update_label, "entries.running.dialog.new_entries", count=1, total=files_count
pw.update_label, "entries.running.dialog.new_entries", total=f"{files_count:n}"
)
pw.show()

iterator.value.connect(
lambda x: (
pw.update_progress(x + 1),
lambda: (
pw.update_label(
Translations.translate_formatted(
"entries.running.dialog.new_entries", count=x + 1, total=files_count
"entries.running.dialog.new_entries", total=f"{files_count:n}"
)
),
)
Expand Down
Loading