Esempio n. 1
0
        def trash(col: Collection) -> None:
            last_progress = 0.0
            remaining = total

            for chunk in chunked_list(fnames, 25):
                col.media.trash_files(chunk)
                remaining -= len(chunk)
                if time.time() - last_progress >= 0.1:
                    self.mw.taskman.run_on_main(
                        lambda: self.mw.progress.update(
                            label=tr.media_check_files_remaining(count=
                                                                 remaining),
                            value=total - remaining,
                            max=total,
                        ))
                    last_progress = time.time()
Esempio n. 2
0
    def _on_trash_files(self, fnames: Sequence[str]) -> None:
        if not askUser(tr.media_check_delete_unused_confirm()):
            return

        self.progress_dialog = self.mw.progress.start()

        last_progress = time.time()
        remaining = len(fnames)
        total = len(fnames)
        try:
            for chunk in chunked_list(fnames, 25):
                self.mw.col.media.trash_files(chunk)
                remaining -= len(chunk)
                if time.time() - last_progress >= 0.3:
                    self.mw.progress.update(
                        tr.media_check_files_remaining(count=remaining))
        finally:
            self.mw.progress.finish()
            self.progress_dialog = None

        tooltip(tr.media_check_delete_unused_complete(count=total))