diff --git a/LightlessSync/UI/DownloadUi.cs b/LightlessSync/UI/DownloadUi.cs index 02416bf..f0ed3fb 100644 --- a/LightlessSync/UI/DownloadUi.cs +++ b/LightlessSync/UI/DownloadUi.cs @@ -25,6 +25,8 @@ public class DownloadUi : WindowMediatorSubscriberBase private readonly ConcurrentDictionary _uploadingPlayers = new(); private readonly Dictionary _smoothed = []; private readonly Dictionary _downloadSpeeds = []; + private readonly Dictionary _downloadInitialTotals = []; + private byte _transferBoxTransparency = 100; private bool _notificationDismissed = true; @@ -66,6 +68,10 @@ public class DownloadUi : WindowMediatorSubscriberBase Mediator.Subscribe(this, (msg) => { _currentDownloads[msg.DownloadId] = msg.DownloadStatus; + // Capture initial totals when download starts + var totalFiles = msg.DownloadStatus.Values.Sum(s => s.TotalFiles); + var totalBytes = msg.DownloadStatus.Values.Sum(s => s.TotalBytes); + _downloadInitialTotals[msg.DownloadId] = (totalFiles, totalBytes); _notificationDismissed = false; }); Mediator.Subscribe(this, (msg) => @@ -435,9 +441,13 @@ public class DownloadUi : WindowMediatorSubscriberBase var handler = transfer.Key; var statuses = transfer.Value.Values; - var playerTotalFiles = statuses.Sum(s => s.TotalFiles); - var playerTransferredFiles = statuses.Sum(s => s.TransferredFiles); - var playerTotalBytes = statuses.Sum(s => s.TotalBytes); + var (playerTotalFiles, playerTotalBytes) = _downloadInitialTotals.TryGetValue(handler, out var totals) + ? totals + : (statuses.Sum(s => s.TotalFiles), statuses.Sum(s => s.TotalBytes)); + + var playerTransferredFiles = statuses.Count(s => + s.DownloadStatus == DownloadStatus.Decompressing || + s.TransferredBytes >= s.TotalBytes); var playerTransferredBytes = statuses.Sum(s => s.TransferredBytes); totalFiles += playerTotalFiles; diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 1c86580..0efc91a 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -1925,14 +1925,25 @@ public class SettingsUi : WindowMediatorSubscriberBase { using (ImRaii.PushIndent(20f)) { - if (_validationTask.IsCompleted) + if (_validationTask.IsCompletedSuccessfully) { UiSharedService.TextWrapped( $"The storage validation has completed and removed {_validationTask.Result.Count} invalid files from storage."); } + else if (_validationTask.IsCanceled) + { + UiSharedService.ColorTextWrapped( + "Storage validation was cancelled.", + UIColors.Get("LightlessYellow")); + } + else if (_validationTask.IsFaulted) + { + UiSharedService.ColorTextWrapped( + "Storage validation failed with an error.", + UIColors.Get("DimRed")); + } else { - UiSharedService.TextWrapped( $"Storage validation is running: {_currentProgress.Item1}/{_currentProgress.Item2}"); if (_currentProgress.Item3 != null) diff --git a/LightlessSync/packages.lock.json b/LightlessSync/packages.lock.json index d47880c..45d7722 100644 --- a/LightlessSync/packages.lock.json +++ b/LightlessSync/packages.lock.json @@ -76,6 +76,19 @@ "Microsoft.AspNetCore.SignalR.Common": "10.0.1" } }, + "Microsoft.Extensions.Caching.Memory": { + "type": "Direct", + "requested": "[10.0.1, )", + "resolved": "10.0.1", + "contentHash": "NxqSP0Ky4dZ5ybszdZCqs1X2C70s+dXflqhYBUh/vhcQVTIooNCXIYnLVbafoAFGZMs51d9+rHxveXs0ZC3SQQ==", + "dependencies": { + "Microsoft.Extensions.Caching.Abstractions": "10.0.1", + "Microsoft.Extensions.DependencyInjection.Abstractions": "10.0.1", + "Microsoft.Extensions.Logging.Abstractions": "10.0.1", + "Microsoft.Extensions.Options": "10.0.1", + "Microsoft.Extensions.Primitives": "10.0.1" + } + }, "Microsoft.Extensions.Hosting": { "type": "Direct", "requested": "[10.0.1, )", @@ -233,6 +246,14 @@ "Microsoft.AspNetCore.SignalR.Common": "10.0.1" } }, + "Microsoft.Extensions.Caching.Abstractions": { + "type": "Transitive", + "resolved": "10.0.1", + "contentHash": "Vb1vVAQDxHpXVdL9fpOX2BzeV7bbhzG4pAcIKRauRl0/VfkE8mq0f+fYC+gWICh3dlzTZInJ/cTeBS2MgU/XvQ==", + "dependencies": { + "Microsoft.Extensions.Primitives": "10.0.1" + } + }, "Microsoft.Extensions.Configuration": { "type": "Transitive", "resolved": "10.0.1", @@ -618,7 +639,7 @@ "FlatSharp.Compiler": "[7.9.0, )", "FlatSharp.Runtime": "[7.9.0, )", "OtterGui": "[1.0.0, )", - "Penumbra.Api": "[5.13.0, )", + "Penumbra.Api": "[5.13.1, )", "Penumbra.String": "[1.0.7, )" } },