From d620010e85edee276c43ee8c7ffa1327d63f8a3e Mon Sep 17 00:00:00 2001 From: Oleksii Holub Date: Thu, 15 Nov 2018 10:26:54 +0200 Subject: [PATCH] Add some safeguarding in case partition limit is less or equal to zero --- DiscordChatExporter.Core/Services/ExportService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Services/ExportService.cs b/DiscordChatExporter.Core/Services/ExportService.cs index 4b68fae..896b974 100644 --- a/DiscordChatExporter.Core/Services/ExportService.cs +++ b/DiscordChatExporter.Core/Services/ExportService.cs @@ -57,7 +57,7 @@ namespace DiscordChatExporter.Core.Services } } - private void ExportChatLogPartitions(IReadOnlyList partitions, string filePath, ExportFormat format) + private void ExportChatLogPartitioned(IReadOnlyList partitions, string filePath, ExportFormat format) { // Split file path into components var dirPath = Path.GetDirectoryName(filePath); @@ -115,7 +115,7 @@ namespace DiscordChatExporter.Core.Services int? partitionLimit = null) { // If partitioning is disabled or there are fewer messages in chat log than the limit - process it without partitioning - if (partitionLimit == null || chatLog.Messages.Count <= partitionLimit) + if (partitionLimit == null || partitionLimit <= 0 || chatLog.Messages.Count <= partitionLimit) { ExportChatLogSingle(chatLog, filePath, format); } @@ -123,7 +123,7 @@ namespace DiscordChatExporter.Core.Services else { var partitions = SplitIntoPartitions(chatLog, partitionLimit.Value); - ExportChatLogPartitions(partitions, filePath, format); + ExportChatLogPartitioned(partitions, filePath, format); } } }