소스 검색

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>
riperiperi 5 년 전
부모
커밋
9852cb9c9e
2개의 변경된 파일21개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 1
      ARMeilleure/Translation/PTC/Ptc.cs
  2. 11 2
      ARMeilleure/Translation/PTC/PtcProfiler.cs

+ 10 - 1
ARMeilleure/Translation/PTC/Ptc.cs

@@ -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);
 

+ 11 - 2
ARMeilleure/Translation/PTC/PtcProfiler.cs

@@ -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
             }
         }
     }
-}
+}