Skip to content

Commit

Permalink
I think I finally got that bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxlider committed Jun 4, 2023
1 parent 6aca3ae commit 76968ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion FASTER/FASTER.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.8.2" />
<PackageReference Include="BytexDigital.Steam" Version="0.8.2-preview.1685575037" />
<PackageReference Include="BytexDigital.Steam" Version="0.8.2-preview.1685631065" />
<PackageReference Include="FontAwesome.WPF" Version="4.7.0.9" />
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
Expand Down
39 changes: 29 additions & 10 deletions FASTER/ViewModel/SteamUpdaterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ private SteamUpdaterViewModel(SteamUpdaterModel model)
};
timer.Tick += Timer_Tick;
timer.IsEnabled = true;


}

private bool _isLoggingIn;
private bool _isDlOverride;
private bool _updaterOnline;
private bool _updaterFaulted;

public SteamUpdaterModel Parameters { get; set; }
public SteamUpdaterModel Parameters { get; set; }


public IDialogCoordinator DialogCoordinator { get; set; }
public IDialogCoordinator DialogCoordinator { get; set; }
private CancellationTokenSource tokenSource = new();

public bool IsDownloading => DownloadTasks.Count > 0 || IsLoggingIn || IsDlOverride;
Expand Down Expand Up @@ -294,12 +292,17 @@ internal async Task<int> RunServerUpdater(string path, uint appId, List<(uint id

Parameters.Output += $"\nFetching informations of app {appId}, depot {depot.id} from Steam ({depots.IndexOf(depot)+1}/{depots.Count})... ";
var downloadHandler = await SteamContentClient.GetAppDataAsync(appId, depot.id, manifestId, tokenSource.Token);
if(downloadHandler.TotalFileSize == 0 && downloadHandler.TotalFileCount == 0)

await Download(downloadHandler, path);
}
catch (ArgumentException ex)
{
if(ex.Message.Contains("'tasks'"))
Parameters.Output += "\nSkipped...";
else
{
Parameters.Output += $"\nNothing to do for {appId}, depot {depot.id}. Skipping...";
continue;
throw;
}
await Download(downloadHandler, path);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -548,8 +551,13 @@ private void SyncDeleteRemovedFiles(string targetDir, Manifest manifest)
private async Task Download(IDownloadHandler downloadHandler, string targetDir)
{
ulong downloadedSize = 0;
bool skipDownload = false;
downloadHandler.FileVerified += (_, args) => Parameters.Output += $"{(args.RequiresDownload ? $"\nFile verified : {args.ManifestFile.FileName} ({Functions.ParseFileSize(args.ManifestFile.TotalSize)})" : "")}";
downloadHandler.VerificationCompleted += (_, args) => Parameters.Output += $"\nVerification completed, {args.QueuedFiles.Count} files queued for download. ({args.QueuedFiles.Sum(f => (double)f.TotalSize)} bytes)";
downloadHandler.VerificationCompleted += (_, args) => {
Parameters.Output += $"\nVerification completed, {args.QueuedFiles.Count} files queued for download. ({args.QueuedFiles.Sum(f => (double)f.TotalSize)} bytes)";
if (args.QueuedFiles.Count == 0)
{skipDownload = true; }
};
downloadHandler.FileDownloaded += (_, args) =>
{
downloadedSize += args.TotalSize;
Expand All @@ -569,8 +577,9 @@ private async Task Download(IDownloadHandler downloadHandler, string targetDir)
DownloadTasks.Add(downloadTask);

Parameters.Output += $"\nDownloading {downloadHandler.TotalFileCount} files with total size of {Functions.ParseFileSize(downloadHandler.TotalFileSize)}...";
Parameters.Output += $"\nVerifying Install...";
Parameters.Progress = 0;
while (!downloadTask.IsCompleted && !downloadTask.IsCanceled && !tokenSource.Token.IsCancellationRequested)
while (!downloadTask.IsCompleted && !downloadTask.IsCanceled && !tokenSource.Token.IsCancellationRequested && !skipDownload)
{

var delayTask = Task.Delay(500, tokenSource.Token);
Expand All @@ -582,6 +591,16 @@ private async Task Download(IDownloadHandler downloadHandler, string targetDir)
Parameters.Progress = downloadHandler.TotalProgress * 100;
}

if (skipDownload)
{
Parameters.Output += "\nSkipping Download...";
Parameters.Progress = 0;
await downloadHandler.DisposeAsync();
DownloadTasks.Remove(downloadTask);
return;
}


if (downloadTask.IsCanceled)
{

Expand Down

0 comments on commit 76968ab

Please sign in to comment.