Skip to content

Commit 21338ce

Browse files
committed
report number of files found for search jobs
1 parent 68ced0c commit 21338ce

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

slsk-batchdl.Cli/Utilities/CliProgressReporter.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ private void ReportJobUpserted(JobSummaryDto summary)
193193
var name = summary.ItemName ?? "";
194194
var detail = summary.QueryText ?? name;
195195

196+
string msg = $"{label}: {WithName(name, detail)}";
197+
if (summary.State == ServerProtocol.JobStates.Done && summary.Kind == ServerJobKind.Search && summary.DiscoveryResultCount.HasValue)
198+
msg += $": Found {summary.DiscoveryResultCount.Value} files";
199+
196200
if (LiveMode)
197-
LogLive(kind, summary, $"{label}: {WithName(name, detail)}");
201+
LogLive(kind, summary, msg);
198202
}
199203

200204
return;
@@ -384,7 +388,12 @@ private static string JobStatusLine(JobSummaryDto summary, string status, string
384388
{
385389
var name = summary.ItemName ?? "";
386390
var d = detail ?? summary.QueryText ?? name;
387-
return $"[{summary.DisplayId}] {GetJobTypePrefix(summary.Kind)}{status}: {WithName(name, d)}";
391+
string line = $"[{summary.DisplayId}] {GetJobTypePrefix(summary.Kind)}{status}: {WithName(name, d)}";
392+
393+
if (summary.State == ServerProtocol.JobStates.Done && summary.Kind == ServerJobKind.Search && summary.DiscoveryResultCount.HasValue)
394+
line += $": Found {summary.DiscoveryResultCount.Value} files";
395+
396+
return line;
388397
}
389398

390399
private void UpsertLiveJob(

slsk-batchdl.Cli/Utilities/EventLogger.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,12 @@ private static string JobStatusLine(JobSummaryDto summary, string status)
332332
_ => $"{char.ToUpperInvariant(summary.Kind.ToWireString()[0])}{summary.Kind.ToWireString()[1..]}Job: "
333333
};
334334
var line = $"[{summary.DisplayId}] {prefix}{status}: {WithName(name, d)}" + ProfileSuffix(summary);
335+
336+
if (summary.State == ServerProtocol.JobStates.Done && summary.Kind == ServerJobKind.Search && summary.DiscoveryResultCount.HasValue)
337+
{
338+
line += $": Found {summary.DiscoveryResultCount.Value} files";
339+
}
340+
335341
if (!string.IsNullOrEmpty(summary.FailureMessage))
336342
line += Environment.NewLine + $" Error: {summary.FailureMessage}";
337343
return line;

slsk-batchdl.Server/ServerProgressLogReporter.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,32 @@ private void OnJobStateChanged(Job job, JobState state)
4343
else if (state == JobState.Done)
4444
{
4545
if (job.Discovery != null && reportedDiscoveryJobs.TryAdd(job.Id, true))
46-
ReportDiscoveryResult(job);
46+
{
47+
if (job is not SearchJob)
48+
ReportDiscoveryResult(job);
49+
}
4750

4851
if (job is AlbumJob aj)
4952
ReportAlbumDownloadCompleted(aj);
5053
else if (job is ExtractJob ej && ej.Result != null)
5154
Log($"[{ej.DisplayId}] ExtractJob: extraction completed: {ej.ToString(true)}");
5255
else if (job is SongJob doneSong)
5356
Log($"[{doneSong.DisplayId}] SongJob: {TerminalLabel(doneSong)}: {SongDisplay(doneSong)}");
57+
else if (job is SearchJob sj)
58+
Log($"[{sj.DisplayId}] SearchJob: {TerminalLabel(sj)}: {sj.ToString(true)}: Found {sj.Discovery?.ResultCount ?? 0} files");
5459
}
5560
else if (IsTerminal(state))
5661
{
5762
if (job.Discovery != null && reportedDiscoveryJobs.TryAdd(job.Id, true))
58-
ReportDiscoveryResult(job);
63+
{
64+
if (job is not SearchJob)
65+
ReportDiscoveryResult(job);
66+
}
5967

6068
if (job is SongJob song)
6169
Log($"[{song.DisplayId}] SongJob: {TerminalLabel(song)}: {SongDisplay(song)}");
70+
else if (job is SearchJob sj)
71+
Log($"[{sj.DisplayId}] SearchJob: {TerminalLabel(sj)}: {sj.ToString(true)}");
6272
}
6373
}
6474

0 commit comments

Comments
 (0)