mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Resolve #881
This commit is contained in:
parent
a6ae0f1dfc
commit
086eb3f5ff
@ -92,7 +92,7 @@ namespace AssetRipper.IO.Files.BundleFiles.FileStream
|
||||
}
|
||||
else if (bytesWritten != uncompressedSize)
|
||||
{
|
||||
DecompressionFailedException.ThrowIncorrectNumberBytesWritten(uncompressedSize, bytesWritten);
|
||||
DecompressionFailedException.ThrowIncorrectNumberBytesWritten(entry.PathFixed, uncompressedSize, bytesWritten);
|
||||
}
|
||||
new MemoryStream(uncompressedBytes).CopyTo(m_cachedBlockStream);
|
||||
break;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AssetRipper.IO.Endian;
|
||||
using AssetRipper.IO.Files.Exceptions;
|
||||
using AssetRipper.IO.Files.Extensions;
|
||||
using AssetRipper.IO.Files.ResourceFiles;
|
||||
using AssetRipper.IO.Files.Streams.Smart;
|
||||
@ -79,9 +80,13 @@ namespace AssetRipper.IO.Files.BundleFiles.FileStream
|
||||
byte[] uncompressedBytes = new byte[uncompressedSize];
|
||||
byte[] compressedBytes = new BinaryReader(stream).ReadBytes(Header.CompressedBlocksInfoSize);
|
||||
int bytesWritten = LZ4Codec.Decode(compressedBytes, uncompressedBytes);
|
||||
if (bytesWritten != uncompressedSize)
|
||||
if (bytesWritten < 0)
|
||||
{
|
||||
throw new Exception($"Incorrect number of bytes written. {bytesWritten} instead of {uncompressedSize} for {compressedBytes.Length} compressed bytes");
|
||||
EncryptedFileException.Throw(NameFixed);
|
||||
}
|
||||
else if (bytesWritten != uncompressedSize)
|
||||
{
|
||||
DecompressionFailedException.ThrowIncorrectNumberBytesWritten(NameFixed, uncompressedSize, bytesWritten);
|
||||
}
|
||||
ReadMetadata(new MemoryStream(uncompressedBytes), uncompressedSize);
|
||||
}
|
||||
|
||||
@ -11,8 +11,8 @@ public sealed class DecompressionFailedException : Exception
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
internal static void ThrowIncorrectNumberBytesWritten(long expected, long actual)
|
||||
internal static void ThrowIncorrectNumberBytesWritten(string fileName, long expected, long actual)
|
||||
{
|
||||
throw new DecompressionFailedException($"Incorrect number of bytes written. Expected {expected}, but was {actual}.");
|
||||
throw new DecompressionFailedException($"Incorrect number of bytes written for '{fileName}' while decompressing. Expected {expected}, but was {actual}.");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user