This commit is contained in:
Tyrrrz
2026-01-01 23:56:12 +02:00
parent 6191855e33
commit 95953f8cf0

View File

@@ -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);