Use backup when PTC compression is corrupt (#1704)

* Use backup when PTC compression is corrupt

* Apply suggestions from code review

Co-authored-by: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>

Co-authored-by: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com>
This commit is contained in:
riperiperi 2020-11-20 01:51:59 +00:00 committed by GitHub
parent c2356a7653
commit 9852cb9c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -196,7 +196,16 @@ namespace ARMeilleure.Translation.PTC
{
int hashSize = md5.HashSize / 8;
deflateStream.CopyTo(stream);
try
{
deflateStream.CopyTo(stream);
}
catch
{
InvalidateCompressedStream(compressedStream);
return false;
}
stream.Seek(0L, SeekOrigin.Begin);

View File

@ -120,7 +120,16 @@ namespace ARMeilleure.Translation.PTC
{
int hashSize = md5.HashSize / 8;
deflateStream.CopyTo(stream);
try
{
deflateStream.CopyTo(stream);
}
catch
{
InvalidateCompressedStream(compressedStream);
return false;
}
stream.Seek(0L, SeekOrigin.Begin);
@ -264,4 +273,4 @@ namespace ARMeilleure.Translation.PTC
}
}
}
}
}