From d565e0b4242b2fcebe1ec517d79366e669e3badd Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Mon, 5 Aug 2024 23:04:02 -0400 Subject: [PATCH] Fix backfilling commenter info progress going over 100% and fix error log --- TwitchDownloaderCore/ChatDownloader.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TwitchDownloaderCore/ChatDownloader.cs b/TwitchDownloaderCore/ChatDownloader.cs index eb85d250..f33ae961 100644 --- a/TwitchDownloaderCore/ChatDownloader.cs +++ b/TwitchDownloaderCore/ChatDownloader.cs @@ -565,12 +565,12 @@ private async Task BackfillUserInfo(ChatRoot chatRoot) userInfo[user.id] = user; } - var percent = (i + BATCH_SIZE) * 100f / userIds.Length; + var percent = Math.Min(i + BATCH_SIZE, userIds.Length) * 100f / userIds.Length; _progress.ReportProgress((int)percent); } catch (Exception e) { - _progress.LogVerbose($"An error occurred while backfilling commenters {i}-{i + BATCH_SIZE}: {e.Message}"); + _progress.LogVerbose($"An error occurred while backfilling commenters {i}-{Math.Min(i + BATCH_SIZE, userIds.Length - 1)}: {e.Message}"); failedInfo = true; } }