diff --git a/DiscordChatExporter.Core/Discord/Dump/DataDump.cs b/DiscordChatExporter.Core/Discord/Dump/DataDump.cs index 0c2f7f7a..67d17f43 100644 --- a/DiscordChatExporter.Core/Discord/Dump/DataDump.cs +++ b/DiscordChatExporter.Core/Discord/Dump/DataDump.cs @@ -41,23 +41,19 @@ public partial class DataDump CancellationToken cancellationToken = default ) { - using var archive = ZipFile.OpenRead(zipFilePath); + await using var archive = await ZipFile.OpenReadAsync(zipFilePath, cancellationToken); - // Try to find the index file with case-insensitive search - // Discord changed the structure from "messages/index.json" to "Messages/index.json" + // Use case-insensitive search to accommodate for different data dump versions // https://github.com/Tyrrrz/DiscordChatExporter/issues/1459 - var entry = archive.Entries.FirstOrDefault(e => - e.FullName.Equals("messages/index.json", StringComparison.OrdinalIgnoreCase) - ); - - if (entry is null) - { - throw new InvalidOperationException( + var entry = + archive.Entries.FirstOrDefault(e => + e.FullName.Equals("messages/index.json", StringComparison.OrdinalIgnoreCase) + ) + ?? throw new InvalidOperationException( "Failed to locate the channel index inside the data package." ); - } - await using var stream = entry.Open(); + await using var stream = await entry.OpenAsync(cancellationToken); using var document = await JsonDocument.ParseAsync(stream, default, cancellationToken); return Parse(document.RootElement);