Skip to content

Commit 57f1672

Browse files
authored
Merge pull request #50 from patchkit-net/hotfix/zlib-exception-in-unpacking
Hotfix: logging the probable cause of the Zlib exception when unpacking
2 parents e112cce + 0d8dde0 commit 57f1672

File tree

4 files changed

+40
-14
lines changed

4 files changed

+40
-14
lines changed

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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using PatchKit.Unity.Patcher.Data;
88
using PatchKit.Unity.Patcher.Debug;
99
using PatchKit.Unity.Utilities;
10+
using SharpRaven;
11+
using SharpRaven.Data;
1012

1113
namespace PatchKit.Unity.Patcher.AppData.Local
1214
{
@@ -149,23 +151,41 @@ private void UnpackRegularFile(Pack1Meta.FileEntry file, Action<double> onProgre
149151
{
150152
using (var gzipStream = new GZipStream(cryptoStream, Ionic.Zlib.CompressionMode.Decompress))
151153
{
152-
using (var fileWritter = new FileStream(destPath, FileMode.Create))
154+
try
153155
{
154-
long bytesProcessed = 0;
155-
const int bufferSize = 131072;
156-
var buffer = new byte[bufferSize];
157-
int count;
158-
while ((count = gzipStream.Read(buffer, 0, bufferSize)) != 0)
156+
using (var fileWritter = new FileStream(destPath, FileMode.Create))
159157
{
160-
fileWritter.Write(buffer, 0, count);
161-
bytesProcessed += count;
162-
onProgress(bytesProcessed / (double) file.Size.Value);
163-
}
164-
if (Platform.IsPosix())
165-
{
166-
Chmod.SetMode(file.Mode.Substring(3), destPath);
158+
long bytesProcessed = 0;
159+
const int bufferSize = 131072;
160+
var buffer = new byte[bufferSize];
161+
int count;
162+
while ((count = gzipStream.Read(buffer, 0, bufferSize)) != 0)
163+
{
164+
fileWritter.Write(buffer, 0, count);
165+
bytesProcessed += count;
166+
onProgress(bytesProcessed / (double) file.Size.Value);
167+
}
168+
if (Platform.IsPosix())
169+
{
170+
Chmod.SetMode(file.Mode.Substring(3), destPath);
171+
}
167172
}
168173
}
174+
catch (Exception e)
175+
{
176+
DebugLogger.LogException(e);
177+
178+
var ravenClient
179+
= new RavenClient("https://cb13d9a4a32f456c8411c79c6ad7be9d:[email protected]/175617");
180+
181+
var sentryEvent = new SentryEvent(e);
182+
var logManager = PatcherLogManager.Instance;
183+
PatcherLogSentryRegistry.AddDataToSentryEvent(sentryEvent, logManager.Storage.Guid.ToString());
184+
185+
ravenClient.Capture(sentryEvent);
186+
187+
throw;
188+
}
169189
}
170190
}
171191
}

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
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [3.9.2]
8+
### Added
9+
- Logging the probable cause of the Zlib exception when unpacking
10+
711
## [3.9.1]
812
### Fixed
913
- Use 'any' instead of 'all' for publish method

0 commit comments

Comments
 (0)