From 57f32b177dbecff2c10cceeaef82e7bc6243d931 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Sep 2023 22:19:18 +0900 Subject: [PATCH] Fix incorrect handling of non-`MemoryStream` pathway --- osu.Game/Database/ImportTask.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/osu.Game/Database/ImportTask.cs b/osu.Game/Database/ImportTask.cs index 6d432aac25..f02f12f8b7 100644 --- a/osu.Game/Database/ImportTask.cs +++ b/osu.Game/Database/ImportTask.cs @@ -58,16 +58,14 @@ namespace osu.Game.Database throw new InvalidFormatException($"{Path} is not a valid archive"); } - if (Stream is MemoryStream memoryStream) - { - if (ZipUtils.IsZipArchive(memoryStream)) - return new ZipArchiveReader(memoryStream, Path); + if (Stream is not MemoryStream memoryStream) + // Path used primarily in tests (converting `ManifestResourceStream`s to `MemoryStream`s). + memoryStream = new MemoryStream(Stream.ReadAllBytesToArray()); - return new MemoryStreamArchiveReader(memoryStream, Path); - } + if (ZipUtils.IsZipArchive(memoryStream)) + return new ZipArchiveReader(memoryStream, Path); - // This isn't used in any current path. May need to reconsider for performance reasons (ie. if we don't expect the incoming stream to be copied out). - return new ByteArrayArchiveReader(Stream.ReadAllBytesToArray(), Path); + return new MemoryStreamArchiveReader(memoryStream, Path); } ///