Skip to content

Commit

Permalink
Merge pull request #120 from /issues/75-TotalDataDownloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 authored May 7, 2024
2 parents a715d1c + aa3bbf2 commit 8676cc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions BattleNetPrefill/TactProductHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,16 @@ await Task.WhenAll(archiveIndexHandler.BuildArchiveIndexesAsync(cdnConfig, ctx),
_ansiConsole.LogMarkupLine("Retrieved product metadata", metadataTimer);

// Actually start the download of any deferred requests
var downloadSuccess = await cdnRequestManager.DownloadQueuedRequestsAsync();
if (downloadSuccess)
var downloadSuccessful = await cdnRequestManager.DownloadQueuedRequestsAsync(_prefillSummaryResult);
if (downloadSuccessful)
{
MarkDownloadAsSuccessful(product, targetVersion.Value);
_prefillSummaryResult.Updated++;
}
else
{
_prefillSummaryResult.FailedApps++;
}

if (!AppConfig.CompareAgainstRealRequests)
{
Expand Down
4 changes: 3 additions & 1 deletion BattleNetPrefill/Web/CdnRequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void QueueRequest(RootFolder rootPath, in MD5Hash hash, in long? startByt
/// false will be returned
/// </summary>
/// <returns>True if all downloads succeeded. False if downloads failed 3 times.</returns>
public async Task<bool> DownloadQueuedRequestsAsync()
public async Task<bool> DownloadQueuedRequestsAsync(PrefillSummaryResult prefillSummaryResult)
{
// Combining requests to improve download performance
var coalescedRequests = RequestUtils.CoalesceRequests(_queuedRequests, true);
Expand Down Expand Up @@ -144,6 +144,8 @@ await _ansiConsole.CreateSpectreProgress(AppConfig.TransferSpeedUnit).StartAsync
// Logging some metrics about the download
_ansiConsole.LogMarkupLine($"Finished in {LightYellow(downloadTimer.FormatElapsedString())} - {Magenta(totalDownloadSize.CalculateBitrate(downloadTimer))}");
_ansiConsole.WriteLine();
//TODO I don't like the fact that I'm passing this down into this method
prefillSummaryResult.TotalBytesTransferred += totalDownloadSize;

return true;
}
Expand Down

0 comments on commit 8676cc9

Please sign in to comment.