Skip to content

Commit

Permalink
Use backup when PTC compression is corrupt (#1704)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
riperiperi and LDj3SNuD committed Nov 20, 2020
1 parent c2356a7 commit 9852cb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion ARMeilleure/Translation/PTC/Ptc.cs
Expand Up @@ -196,7 +196,16 @@ private static bool Load(string fileName)
{
int hashSize = md5.HashSize / 8;

deflateStream.CopyTo(stream);
try
{
deflateStream.CopyTo(stream);
}
catch
{
InvalidateCompressedStream(compressedStream);

return false;
}

stream.Seek(0L, SeekOrigin.Begin);

Expand Down
13 changes: 11 additions & 2 deletions ARMeilleure/Translation/PTC/PtcProfiler.cs
Expand Up @@ -120,7 +120,16 @@ private static bool Load(string fileName)
{
int hashSize = md5.HashSize / 8;

deflateStream.CopyTo(stream);
try
{
deflateStream.CopyTo(stream);
}
catch
{
InvalidateCompressedStream(compressedStream);

return false;
}

stream.Seek(0L, SeekOrigin.Begin);

Expand Down Expand Up @@ -264,4 +273,4 @@ public static void Dispose()
}
}
}
}
}

0 comments on commit 9852cb9

Please sign in to comment.