Horde: Fix Gzip compression in bundles.

[CL 27375770 by Ben Marsh in ue5-main branch]
This commit is contained in:
Ben Marsh
2023-08-25 10:00:17 -04:00
parent 2eedfb164c
commit b32ea052df

View File

@@ -1232,8 +1232,11 @@ namespace EpicGames.Horde.Storage.Bundles
case BundleCompressionFormat.Gzip:
{
using MemoryStream outputStream = new MemoryStream(input.Length);
using GZipStream gzipStream = new GZipStream(outputStream, CompressionLevel.Fastest);
gzipStream.Write(input.Span);
using (GZipStream gzipStream = new GZipStream(outputStream, CompressionLevel.Fastest, true))
{
gzipStream.Write(input.Span);
}
writer.WriteFixedLengthBytes(outputStream.ToArray());
return (int)outputStream.Length;
@@ -1276,8 +1279,13 @@ namespace EpicGames.Horde.Storage.Bundles
case BundleCompressionFormat.Gzip:
{
using ReadOnlyMemoryStream inputStream = new ReadOnlyMemoryStream(input);
using GZipStream outputStream = new GZipStream(new MemoryWriterStream(new MemoryWriter(output)), CompressionMode.Decompress, false);
inputStream.CopyTo(outputStream);
using GZipStream inflatedStream = new GZipStream(inputStream, CompressionMode.Decompress, true);
int length = inflatedStream.Read(output.Span);
if (length != output.Length)
{
throw new InvalidDataException($"Decoded data is shorter than expected (expected {output.Length} bytes, got {length} bytes)");
}
break;
}
case BundleCompressionFormat.Oodle: