Skip to content

Commit fc0d160

Browse files
committed
feat: Delete all unlinked entries at once (TagStudioDev#617)
This technically removes the usefulness progress indicator, but brief testing on my end had it delete ~8000 entries in less time than it took me to see if the progress indicator was properly indeterminate or not
1 parent b7e652a commit fc0d160

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

tagstudio/src/core/utils/missing_files.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ def fix_missing_files(self) -> Iterator[int]:
6060
self.missing_files.remove(entry)
6161
yield i
6262

63-
def execute_deletion(self) -> Iterator[int]:
64-
for i, missing in enumerate(self.missing_files, start=1):
65-
# TODO - optimize this by removing multiple entries at once
66-
self.library.remove_entries([missing.id])
67-
yield i
63+
def execute_deletion(self) -> None:
64+
self.library.remove_entries(list(map(lambda missing: missing.id, self.missing_files)))
6865

6966
self.missing_files = []

tagstudio/src/qt/modals/delete_unlinked.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,15 @@ def refresh_list(self):
8181

8282
def delete_entries(self):
8383
pw = ProgressWidget(
84-
window_title="Deleting Entries",
84+
window_title=f"Deleting {self.tracker.missing_files_count} Entries",
8585
label_text="",
8686
cancel_button_text=None,
8787
minimum=0,
88-
maximum=self.tracker.missing_files_count,
88+
maximum=0,
8989
)
9090
pw.show()
9191

92-
iterator = FunctionIterator(self.tracker.execute_deletion)
93-
files_count = self.tracker.missing_files_count
94-
iterator.value.connect(
95-
lambda idx: (
96-
pw.update_progress(idx),
97-
pw.update_label(f"Deleting {idx}/{files_count} Unlinked Entries"),
98-
)
99-
)
100-
101-
r = CustomRunnable(iterator.run)
92+
r = CustomRunnable(self.tracker.execute_deletion)
10293
QThreadPool.globalInstance().start(r)
10394
r.done.connect(
10495
lambda: (

0 commit comments

Comments
 (0)