Skip to content

Commit df12188

Browse files
committed
Fix #2
1 parent 5369f98 commit df12188

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Assets/PatchKit Patcher/Scripts/AppData/Remote/RemoteMetaData.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ public RemoteMetaData([NotNull] string appSecret, [NotNull] IRequestTimeoutCalcu
7979
public int GetLatestVersionId(bool retryRequests = true)
8080
{
8181
DebugLogger.Log("Getting latest version id.");
82+
DebugLogger.Log("retryRequests = " + retryRequests);
8283
var m = retryRequests ? _mainApiConnection : _mainApiConnectionWithoutRetry;
8384
return m.GetAppLatestAppVersionId(_appSecret).Id;
8485
}
8586

8687
public Api.Models.Main.App GetAppInfo(bool retryRequests = true)
8788
{
8889
DebugLogger.Log("Getting app info.");
90+
DebugLogger.Log("retryRequests = " + retryRequests);
8991
var m = retryRequests ? _mainApiConnection : _mainApiConnectionWithoutRetry;
9092
return m.GetApplicationInfo(_appSecret);
9193
}

Assets/PatchKit Patcher/Scripts/AppData/Remote/WebRequestWraps/UnityHttpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private HttpStatusCode ReadStatusCode(WWWResult result)
9292
{
9393
_logger.LogDebug("Reading status code...");
9494

95-
if (!result.ResponseHeaders.ContainsKey("STATUS"))
95+
if (result.ResponseHeaders == null || !result.ResponseHeaders.ContainsKey("STATUS"))
9696
{
9797
// Based on tests, if response doesn't contain status it has probably timed out.
9898
_logger.LogWarning("Response is missing STATUS header. Marking it as timed out.");

Assets/PatchKit Patcher/Scripts/Patcher.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -641,17 +641,17 @@ private void ThreadExecuteUserDecision(CancellationToken cancellationToken)
641641
break;
642642
case UserDecision.InstallAppAutomatically:
643643
displayWarningInsteadOfError = _app.IsInstalled();
644-
ThreadUpdateApp(cancellationToken);
644+
ThreadUpdateApp(true, cancellationToken);
645645
break;
646646
case UserDecision.InstallApp:
647-
ThreadUpdateApp(cancellationToken);
647+
ThreadUpdateApp(false, cancellationToken);
648648
break;
649649
case UserDecision.CheckForAppUpdatesAutomatically:
650650
displayWarningInsteadOfError = _app.IsInstalled();
651-
ThreadUpdateApp(cancellationToken);
651+
ThreadUpdateApp(true, cancellationToken);
652652
break;
653653
case UserDecision.CheckForAppUpdates:
654-
ThreadUpdateApp(cancellationToken);
654+
ThreadUpdateApp(false, cancellationToken);
655655
break;
656656
}
657657

@@ -679,7 +679,15 @@ private void ThreadExecuteUserDecision(CancellationToken cancellationToken)
679679
catch (ApiConnectionException e)
680680
{
681681
DebugLogger.LogException(e);
682-
ThreadDisplayError(PatcherError.NoInternetConnection, cancellationToken);
682+
683+
if (displayWarningInsteadOfError)
684+
{
685+
_warning.Value = "Unable to check for updates. Please check your internet connection.";
686+
}
687+
else
688+
{
689+
ThreadDisplayError(PatcherError.NoInternetConnection, cancellationToken);
690+
}
683691
}
684692
catch (NotEnoughtDiskSpaceException e)
685693
{
@@ -759,12 +767,12 @@ private void ThreadStartApp()
759767
UnityDispatcher.Invoke(Quit);
760768
}
761769

762-
private void ThreadUpdateApp(CancellationToken cancellationToken)
770+
private void ThreadUpdateApp(bool automatically, CancellationToken cancellationToken)
763771
{
764772
_state.Value = PatcherState.UpdatingApp;
765773

766-
_appInfo.Value = _app.RemoteMetaData.GetAppInfo();
767-
_remoteVersionId.Value = _app.GetLatestVersionId(false);
774+
_appInfo.Value = _app.RemoteMetaData.GetAppInfo(!automatically);
775+
_remoteVersionId.Value = _app.GetLatestVersionId(!automatically);
768776
if (_app.IsInstalled())
769777
{
770778
_localVersionId.Value = _app.GetInstalledVersionId();

0 commit comments

Comments
 (0)