Skip to content

Commit

Permalink
Ensure a final list of files written is output (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeYallop authored May 26, 2024
1 parent c819316 commit a49aa6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 0 additions & 1 deletion WaybackDownloader/Services/PageWorkerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ private async Task EvaluateLimitAsync(string outputDir, int requestedDownloadLim

private async ValueTask DisposeAllAsync()
{
AnsiConsole.WriteLine("Waiting up to 10 seconds for workers to finish.");
await WaitForCompletionAsync().WaitAsync(TimeSpan.FromSeconds(10), CancellationToken.None).ConfigureAwait(false);
return;
}
Expand Down
29 changes: 17 additions & 12 deletions WaybackDownloader/Ui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public async Task DrawUiAsync(CancellationToken cancellationToken)
_requiresUpdate = false;
}
await statsTask.ConfigureAwait(false);
LogStats(Counters.FilesWritten.Count, Counters.FilesSkipped.Count, Counters.FilesUpdated.Count);
}

private static readonly Style BoldStyle = new(decoration: Decoration.Bold);
Expand All @@ -47,22 +48,26 @@ private async Task LogStatsAsync(CancellationToken cancellationToken)
var filesSkipped = Counters.FilesSkipped.Count;
var filesUpdated = Counters.FilesUpdated.Count;

var p = new Paragraph();
p.Append("Files Written: ", BoldStyle);
p.Append(filesWritten.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(", ");
p.Append("Files Skipped: ", BoldStyle);
p.Append(filesSkipped.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(", ");
p.Append("Files Updated: ", BoldStyle);
p.Append(filesUpdated.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(Environment.NewLine);
_console.Write(p);

LogStats(filesWritten, filesSkipped, filesUpdated);
await Task.Delay(3000, default).ConfigureAwait(false);
}
}

public void LogStats(long filesWritten, long filesSkipped, long filesUpdated)
{
var p = new Paragraph();
p.Append("Files Written: ", BoldStyle);
p.Append(filesWritten.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(", ");
p.Append("Files Skipped: ", BoldStyle);
p.Append(filesSkipped.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(", ");
p.Append("Files Updated: ", BoldStyle);
p.Append(filesUpdated.ToString(CultureInfo.CurrentCulture), NumberStyle);
p.Append(Environment.NewLine);
_console.Write(p);
}

private ImmutableArray<LogMessage> ReadMessages()
{
var newMessages = _logMessages.DrainMessages();
Expand Down

0 comments on commit a49aa6f

Please sign in to comment.