From 76968ab4752b8cc04e284660eac3d7e397925aed Mon Sep 17 00:00:00 2001 From: Keelah Date: Sun, 4 Jun 2023 18:34:17 +0200 Subject: [PATCH] I think I finally got that bug --- FASTER/FASTER.csproj | 2 +- FASTER/ViewModel/SteamUpdaterViewModel.cs | 39 +++++++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/FASTER/FASTER.csproj b/FASTER/FASTER.csproj index 7599b55c..b677f386 100644 --- a/FASTER/FASTER.csproj +++ b/FASTER/FASTER.csproj @@ -52,7 +52,7 @@ - + diff --git a/FASTER/ViewModel/SteamUpdaterViewModel.cs b/FASTER/ViewModel/SteamUpdaterViewModel.cs index 28e5bffe..a9bfb50a 100644 --- a/FASTER/ViewModel/SteamUpdaterViewModel.cs +++ b/FASTER/ViewModel/SteamUpdaterViewModel.cs @@ -48,8 +48,6 @@ private SteamUpdaterViewModel(SteamUpdaterModel model) }; timer.Tick += Timer_Tick; timer.IsEnabled = true; - - } private bool _isLoggingIn; @@ -57,10 +55,10 @@ private SteamUpdaterViewModel(SteamUpdaterModel model) 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; @@ -294,12 +292,17 @@ internal async Task 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) { @@ -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; @@ -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); @@ -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) {