diff --git a/tagstudio/src/core/library.py b/tagstudio/src/core/library.py index 8f1aa83d..375252e6 100644 --- a/tagstudio/src/core/library.py +++ b/tagstudio/src/core/library.py @@ -962,12 +962,15 @@ class Library: # print('') # Sorts the files by date modified, descending. - try: - self.files_not_in_library = sorted( - self.files_not_in_library, key=lambda t: -os.stat(os.path.normpath(self.library_dir + '/' + t)).st_ctime) - except FileExistsError: - print(f'[LIBRARY] [ERROR] Couldn\'t sort files, some were moved during the scanning/sorting process.') - pass + if len(self.files_not_in_library) <= 100000: + try: + self.files_not_in_library = sorted( + self.files_not_in_library, key=lambda t: -os.stat(os.path.normpath(self.library_dir + '/' + t)).st_ctime) + except (FileExistsError, FileNotFoundError): + print(f'[LIBRARY][ERROR] Couldn\'t sort files, some were moved during the scanning/sorting process.') + pass + else: + print(f'[LIBRARY][INFO] Not bothering to sort files because there\'s OVER 100,000! Better sorting methods will be added in the future.') def refresh_missing_files(self): """Tracks the number of Entries that point to an invalid file path.""" diff --git a/tagstudio/src/qt/ts_qt.py b/tagstudio/src/qt/ts_qt.py index ef94c805..7cc4598d 100644 --- a/tagstudio/src/qt/ts_qt.py +++ b/tagstudio/src/qt/ts_qt.py @@ -515,6 +515,8 @@ class QtDriver(QObject): iterator.value.connect(lambda x: pw.update_progress(x+1)) iterator.value.connect(lambda x: pw.update_label(f'Scanning Directories for New Files...\n{x+1} File{"s" if x+1 != 1 else ""} Searched, {len(self.lib.files_not_in_library)} New Files Found')) r = CustomRunnable(lambda:iterator.run()) + # r.done.connect(lambda: (pw.hide(), pw.deleteLater(), self.filter_items(''))) + # vvv This one runs the macros when adding new files to the library. r.done.connect(lambda: (pw.hide(), pw.deleteLater(), self.add_new_files_runnable())) QThreadPool.globalInstance().start(r) @@ -568,12 +570,15 @@ class QtDriver(QObject): def new_file_macros_runnable(self, new_ids): """Threaded method that runs macros on a set of Entry IDs.""" # sleep(1) - logging.info(f'ANFR: {QThread.currentThread()}') - for i, id in enumerate(new_ids): - # pb.setValue(i) - # pb.setLabelText(f'Running Configured Macros on {i}/{len(new_ids)} New Entries') - # self.run_macro('autofill', id) - yield i + # logging.info(f'ANFR: {QThread.currentThread()}') + # for i, id in enumerate(new_ids): + # # pb.setValue(i) + # # pb.setLabelText(f'Running Configured Macros on {i}/{len(new_ids)} New Entries') + # # self.run_macro('autofill', id) + + # NOTE: I don't know. I don't know why it needs this. The whole program + # falls apart if this method doesn't run, and it DOESN'T DO ANYTHING + yield 0 # self.main_window.statusbar.showMessage('', 3)