Skip to content

Commit 9ddb066

Browse files
authored
Merge pull request #44 from jitsuCM/fix-failed-download-handling
Improved failed/succeeded files error handling and counting
2 parents 47ea9e6 + 6949ac2 commit 9ddb066

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/kemonodownloader/creator_downloader.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,19 +1811,24 @@ def update_creator_file_progress(self, file_index, progress):
18111811
def update_file_completion(self, file_index, file_url, success):
18121812
"""Update file completion status and check overall progress."""
18131813
with self.completed_files_lock, self.failed_files_lock:
1814-
if file_url not in self.completed_files and file_url not in self.failed_files:
1815-
if success:
1814+
if success:
1815+
if file_url not in self.completed_files:
18161816
self.completed_files.add(file_url)
1817+
# Remove from failed_files if it was there before
1818+
if file_url in self.failed_files:
1819+
del self.failed_files[file_url]
18171820
self.append_log_to_console(translate("log_debug", translate("file_completed", file_url, len(self.completed_files), self.total_files_to_download)), "INFO")
18181821
else:
1819-
# Find the CreatorDownloadThread to get the error message
1820-
error_message = "Unknown error"
1821-
for thread in self.active_threads:
1822-
if isinstance(thread, CreatorDownloadThread):
1823-
error_message = thread.failed_files.get(file_url, "Unknown error")
1824-
break
1825-
self.failed_files[file_url] = error_message
1826-
self.append_log_to_console(translate("log_debug", translate("file_failed", file_url, len(self.failed_files))), "INFO")
1822+
# Only mark as failed if not already completed
1823+
if file_url not in self.completed_files:
1824+
# Find the CreatorDownloadThread to get the error message
1825+
error_message = "Unknown error"
1826+
for thread in self.active_threads:
1827+
if isinstance(thread, CreatorDownloadThread):
1828+
error_message = thread.failed_files.get(file_url, "Unknown error")
1829+
break
1830+
self.failed_files[file_url] = error_message
1831+
self.append_log_to_console(translate("log_debug", translate("file_failed", file_url, len(self.failed_files))), "INFO")
18271832
self.update_overall_progress()
18281833
# Check if all files have been attempted (successful or failed)
18291834
if self.total_files_to_download > 0 and len(self.completed_files) + len(self.failed_files) >= self.total_files_to_download:

0 commit comments

Comments
 (0)