1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Fix incorrect handling of non-MemoryStream pathway

This commit is contained in:
Dean Herbert 2023-09-14 22:19:18 +09:00
parent 364094fcf2
commit 57f32b177d

View File

@ -58,18 +58,16 @@ namespace osu.Game.Database
throw new InvalidFormatException($"{Path} is not a valid archive");
}
if (Stream is MemoryStream memoryStream)
{
if (Stream is not MemoryStream memoryStream)
// Path used primarily in tests (converting `ManifestResourceStream`s to `MemoryStream`s).
memoryStream = new MemoryStream(Stream.ReadAllBytesToArray());
if (ZipUtils.IsZipArchive(memoryStream))
return new ZipArchiveReader(memoryStream, Path);
return new MemoryStreamArchiveReader(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);
}
/// <summary>
/// Deletes the file that is encapsulated by this <see cref="ImportTask"/>.
/// </summary>