Skip to content

Commit 820ab5a

Browse files
committed
shares.py: accurate current_folder_count during rescan
1 parent 0ec9d5d commit 820ab5a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pynicotine/shares.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ def scan_shared_folder(self, shared_folder_path, old_mtimes, old_files):
532532
# Sharing a folder twice, no go
533533
continue
534534

535+
self.queue.put(self.current_folder_count)
536+
535537
file_list = []
536538

537539
try:
@@ -544,11 +546,7 @@ def scan_shared_folder(self, shared_folder_path, old_mtimes, old_files):
544546
if self.is_hidden(path, entry=entry):
545547
continue
546548

547-
self.current_folder_count += 1
548549
folder_paths.append(path)
549-
550-
if not self.current_folder_count % 100:
551-
self.queue.put(self.current_folder_count)
552550
continue
553551

554552
try:
@@ -593,6 +591,7 @@ def scan_shared_folder(self, shared_folder_path, old_mtimes, old_files):
593591
)
594592

595593
self.streams[virtual_folder_path] = self.get_folder_stream(file_list)
594+
self.current_folder_count += 1
596595

597596
def get_audio_tag(self, file_path, size):
598597

@@ -1107,7 +1106,7 @@ def _process_scanner(self, scanner_queue, emit_event=None):
11071106

11081107
successful = True
11091108

1110-
while self._scanner_process.is_alive():
1109+
while self._scanner_process.is_alive() and successful:
11111110
# Cooldown
11121111
time.sleep(0.05)
11131112

@@ -1118,16 +1117,16 @@ def _process_scanner(self, scanner_queue, emit_event=None):
11181117
successful = False
11191118
break
11201119

1121-
if isinstance(item, int):
1120+
if isinstance(item, tuple):
1121+
self.file_path_index = item
1122+
1123+
elif isinstance(item, int):
11221124
if emit_event is not None:
11231125
emit_event("shares-scanning", item)
11241126

11251127
elif isinstance(item, ScannerLogMessage):
11261128
log.add(item.msg, item.msg_args)
11271129

1128-
elif isinstance(item, tuple):
1129-
self.file_path_index = item
1130-
11311130
elif isinstance(item, SharedFileListResponse):
11321131
self.compressed_shares[item.permission_level] = item
11331132

0 commit comments

Comments
 (0)