Skip to content

Commit fdb6a4f

Browse files
committed
Cherrypick: handling the ZLib exception
1 parent c1be239 commit fdb6a4f

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

Assets/PatchKit Patcher/Scripts/AppData/Local/Pack1Unarchiver.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using PatchKit.Unity.Patcher.Data;
99
using PatchKit.Unity.Patcher.Debug;
1010
using PatchKit.Unity.Utilities;
11+
using SharpRaven;
12+
using SharpRaven.Data;
1113

1214
namespace PatchKit.Unity.Patcher.AppData.Local
1315
{
@@ -225,16 +227,33 @@ private void ExtractFileFromStream(
225227
{
226228
using (var gzipStream = new GZipStream(cryptoStream, Ionic.Zlib.CompressionMode.Decompress))
227229
{
228-
long bytesProcessed = 0;
229-
const int bufferSize = 128 * 1024;
230-
var buffer = new byte[bufferSize];
231-
int count;
232-
while ((count = gzipStream.Read(buffer, 0, bufferSize)) != 0)
230+
try
233231
{
234-
cancellationToken.ThrowIfCancellationRequested();
235-
targetStream.Write(buffer, 0, count);
236-
bytesProcessed += count;
237-
onProgress((double) gzipStream.Position / file.Size.Value);
232+
long bytesProcessed = 0;
233+
const int bufferSize = 128 * 1024;
234+
var buffer = new byte[bufferSize];
235+
int count;
236+
while ((count = gzipStream.Read(buffer, 0, bufferSize)) != 0)
237+
{
238+
targetStream.Write(buffer, 0, count);
239+
bytesProcessed += count;
240+
onProgress(bytesProcessed / (double) file.Size.Value);
241+
}
242+
}
243+
catch (Exception e)
244+
{
245+
DebugLogger.LogException(e);
246+
247+
var ravenClient
248+
= new RavenClient("https://cb13d9a4a32f456c8411c79c6ad7be9d:[email protected]/175617");
249+
250+
var sentryEvent = new SentryEvent(e);
251+
var logManager = PatcherLogManager.Instance;
252+
PatcherLogSentryRegistry.AddDataToSentryEvent(sentryEvent, logManager.Storage.Guid.ToString());
253+
254+
ravenClient.Capture(sentryEvent);
255+
256+
throw;
238257
}
239258
}
240259
}

Assets/PatchKit Patcher/Scripts/Debug/PatcherLogManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public static PatcherLogManager Instance
4545
private PatcherLogRegisterTriggers _registerTriggers;
4646

4747
private PatcherLogStorage _storage;
48+
49+
public PatcherLogStorage Storage { get { return _storage; } }
4850

4951
private PatcherLogSentryRegistry _sentryRegistry;
5052

Assets/PatchKit Patcher/Scripts/Debug/PatcherLogSentryRegistry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void RegisterWithException(Exception exception, string logFileGuid)
4141
}, logFileGuid);
4242
}
4343

44-
private static void AddDataToSentryEvent(SentryEvent sentryEvent, string logFileGuid)
44+
public static void AddDataToSentryEvent(SentryEvent sentryEvent, string logFileGuid)
4545
{
4646
sentryEvent.Exception.Data.Add("log-guid", logFileGuid);
4747
sentryEvent.Exception.Data.Add("log-link", string.Format(

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3030
- Rename PK_PATCHER_MAIN_URL environmental variable to PK_PATCHER_API_URL
3131
- The patcher will now delete the lockfile when quitting
3232

33+
## [3.9.2]
34+
### Added
35+
- Logging the probable cause of the Zlib exception when unpacking
36+
3337
## [3.9.1]
3438
### Fixed
3539
- Use 'any' instead of 'all' for publish method

0 commit comments

Comments
 (0)