Skip to content

Commit acbc33b

Browse files
Szczyrkwitcher112
authored andcommitted
Code refactoring
1 parent 2f2a485 commit acbc33b

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ public UnityMessageWriter([NotNull] IMessageFormatter formatter)
1818

1919
public void Write(Message message, MessageContext messageContext)
2020
{
21+
var text = _formatter.Format(message, messageContext);
2122
var patcher = Patcher.Instance;
22-
var text = _formatter.Format(message, messageContext)
23-
.Replace(patcher.AppSecret, patcher.TraceableAppSecret);
23+
if (!string.IsNullOrEmpty(patcher.AppSecret))
24+
{
25+
text = text.Replace(patcher.AppSecret, patcher.TraceableAppSecret);
26+
}
2427

2528
switch (message.Type)
2629
{

Assets/PatchKit Patcher/Scripts/Patcher.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,20 @@ public static Patcher Instance
8787

8888
private PatchKit.Unity.Patcher.Cancellation.CancellationTokenSource _updateAppCancellationTokenSource;
8989

90-
public string TraceableAppSecret { get; private set; }
90+
public string TraceableAppSecret
91+
{
92+
get
93+
{
94+
if (_traceableAppSecret == null)
95+
{
96+
_traceableAppSecret = BuildTraceableAppSecret();
97+
}
98+
99+
return _traceableAppSecret;
100+
}
101+
}
102+
103+
private string _traceableAppSecret;
91104

92105
public string AppSecret { get; private set; }
93106

@@ -517,8 +530,8 @@ private void ThreadLoadPatcherData()
517530
_data.Value = inputArgumentsPatcherDataReader.Read();
518531
#endif
519532
AppSecret = _data.Value.AppSecret;
520-
BuildTraceableAppSecret(AppSecret);
521-
DebugLogger.LogVariable(AppSecret, "Data.AppSecret");
533+
534+
DebugLogger.LogVariable(_data.Value.AppSecret, "Data.AppSecret");
522535
DebugLogger.LogVariable(_data.Value.AppDataPath, "Data.AppDataPath");
523536
DebugLogger.LogVariable(_data.Value.OverrideLatestVersionId, "Data.OverrideLatestVersionId");
524537
DebugLogger.LogVariable(_data.Value.LockFilePath, "Data.LockFilePath");
@@ -960,10 +973,10 @@ private bool ThreadTryRestartWithRequestForPermissions()
960973
}
961974
}
962975

963-
private void BuildTraceableAppSecret(string appSecret)
976+
private string BuildTraceableAppSecret()
964977
{
965-
TraceableAppSecret = string.Format("{0}...{1}", appSecret.Substring(0, 6),
966-
appSecret.Substring(appSecret.Length - 6));
978+
return string.Format("{0}...{1}", AppSecret.Substring(0, 6),
979+
AppSecret.Substring(AppSecret.Length - 6));
967980
}
968981
}
969982
}

0 commit comments

Comments
 (0)