Skip to content

Commit

Permalink
cancel downloads before showing error message if a patch failed
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Apr 13, 2024
1 parent bb642f3 commit 6e0829a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
12 changes: 3 additions & 9 deletions src/XIVLauncher.Common/Game/Patch/PatchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ void HandleError(string context)
this.hasError = true;
CancelAllDownloads();
OnFail?.Invoke(download.Patch, context);
CancelAllDownloads();
Task.Run(async () => await UnInitializeAcquisition(), new CancellationTokenSource(5000).Token).GetAwaiter().GetResult();
try
Expand All @@ -250,7 +250,7 @@ void HandleError(string context)
// This is fine. We will catch it next try.
Log.Error(ex, "Could not delete patch file");
}
Environment.Exit(0);
}
Expand Down Expand Up @@ -302,10 +302,6 @@ void HandleError(string context)

public void CancelAllDownloads()
{
#if !DEBUG
return;
#endif

foreach (var downloadService in DownloadServices)
{
if (downloadService == null)
Expand Down Expand Up @@ -469,7 +465,7 @@ private static HashCheckResult CheckPatchValidity(PatchListEntry patchListEntry,
return HashCheckResult.UnknownHashType;
}

var stream = path.OpenRead();
using var stream = path.OpenRead();

if (stream.Length != patchListEntry.Length)
{
Expand Down Expand Up @@ -503,11 +499,9 @@ private static HashCheckResult CheckPatchValidity(PatchListEntry patchListEntry,
if (sb.ToString() == patchListEntry.Hashes[i])
continue;

stream.Close();
return HashCheckResult.BadHash;
}

stream.Close();
return HashCheckResult.Pass;
}

Expand Down
2 changes: 1 addition & 1 deletion src/XIVLauncher/Windows/PatchDownloadDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<TextBlock x:Name="InstallingText" Foreground="{DynamicResource MaterialDesignBody}" HorizontalAlignment="Center" Text="{Binding PatchInstallingLoc}"></TextBlock>
<ProgressBar IsIndeterminate="True" Margin="0,0,0,11" />

<TextBlock x:Name="BytesLeftText" Foreground="DarkGray" Margin="0,8,0,12" TextAlignment="Center" Text="{Binding PatchPreparingLoc}" MouseLeftButtonUp="BytesLeftText_OnMouseLeftButtonUp"/>
<TextBlock x:Name="BytesLeftText" Foreground="DarkGray" Margin="0,8,0,12" TextAlignment="Center" Text="{Binding PatchPreparingLoc}"/>
</StackPanel>
</materialDesign:Card>
</Grid>
Expand Down
7 changes: 0 additions & 7 deletions src/XIVLauncher/Windows/PatchDownloadDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,5 @@ private void PatchDownloadDialog_OnClosing(object sender, CancelEventArgs e)
{
e.Cancel = true; // We can't cancel patching yet, big TODO
}

private void BytesLeftText_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
#if DEBUG
_manager.CancelAllDownloads();
#endif
}
}
}

0 comments on commit 6e0829a

Please sign in to comment.