Fix DreamMaker progress stages

This commit is contained in:
Jordan Brown
2022-10-01 19:16:13 -04:00
parent 6345797b31
commit cbb8a05d96
2 changed files with 6 additions and 9 deletions
@@ -717,13 +717,9 @@ namespace Tgstation.Server.Host.Components.Deployment
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
async Task ProgressTask(JobProgressReporter progressReporter, TimeSpan? estimatedDuration, CancellationToken cancellationToken)
{
if (!estimatedDuration.HasValue)
{
progressReporter.ReportProgress(null);
return;
}
progressReporter.ReportProgress(0);
var noEstimate = !estimatedDuration.HasValue;
progressReporter.StageName = currentStage;
progressReporter.ReportProgress(noEstimate ? null : 0);
var sleepInterval = estimatedDuration.HasValue ? estimatedDuration.Value / 100 : TimeSpan.FromMilliseconds(250);
@@ -733,7 +729,8 @@ namespace Tgstation.Server.Host.Components.Deployment
for (var iteration = 0; iteration < (estimatedDuration.HasValue ? 99 : Int32.MaxValue); ++iteration)
{
await Task.Delay(sleepInterval, cancellationToken);
progressReporter.ReportProgress(sleepInterval * (iteration + 1) / estimatedDuration.Value);
progressReporter.StageName = currentStage;
progressReporter.ReportProgress(noEstimate ? null : sleepInterval * (iteration + 1) / estimatedDuration.Value);
}
}
catch (OperationCanceledException)
@@ -14,7 +14,7 @@ namespace Tgstation.Server.Host.Jobs
/// <summary>
/// The name of the current stage.
/// </summary>
public string StageName { get; }
public string StageName { get; set; }
/// <summary>
/// The <see cref="ILogger{TCategoryName}"/> for the <see cref="JobProgressReporter"/>.