Skip to content

Commit 2ec91cd

Browse files
committed
reorganize core
see Sockseek.Core/README.md
1 parent c069dab commit 2ec91cd

109 files changed

Lines changed: 4874 additions & 3892 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Sockseek.Cli/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ await backend.SubmitExtractJobAsync(
419419
{
420420
SockseekLog.Trace("Main: Entered finally block. Disposing clientManager...");
421421
engine.Cancel();
422+
await engine.DisposeAsync();
422423
await cts.CancelAsync();
423424
cliReporter?.Stop();
424425
clientManager.Dispose();

Sockseek.Cli/Services/LocalCliBackend.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public LocalCliBackend(
3737
stateStore.JobUpserted += summary => Publish("job.upserted", summary);
3838
stateStore.WorkflowUpserted += summary => Publish("workflow.upserted", summary);
3939
stateStore.SearchUpdated += update => Publish("search.updated", update);
40-
new EngineEventDtoAdapter(GetSummary, Publish).Attach(engine.Events);
40+
new EngineEventDtoAdapter(GetSummary, Publish).Attach(engine.Events, engine.SearchEvents);
4141
}
4242

4343
public Task<JobSummaryDto> SubmitExtractJobAsync(SubmitExtractJobRequestDto request, CancellationToken ct = default)
@@ -519,24 +519,14 @@ public Task<bool> CancelJobAsync(Guid jobId, CancellationToken ct = default)
519519
{
520520
ct.ThrowIfCancellationRequested();
521521

522-
var job = engine.GetJob(jobId);
523-
if (job == null)
524-
return Task.FromResult(false);
525-
526-
job.Cancel(JobCancellationSource.UserRequestedJob);
527-
return Task.FromResult(true);
522+
return Task.FromResult(engine.CancelJob(jobId));
528523
}
529524

530525
public async Task<bool> CancelJobByDisplayIdAsync(int displayId, Guid? workflowId = null, CancellationToken ct = default)
531526
{
532527
ct.ThrowIfCancellationRequested();
533528

534-
var job = engine.GetJob(displayId);
535-
if (job == null || (workflowId.HasValue && job.WorkflowId != workflowId.Value))
536-
return false;
537-
538-
job.Cancel(JobCancellationSource.UserRequestedJob);
539-
return await Task.FromResult(true);
529+
return await Task.FromResult(engine.CancelJobByDisplayId(displayId, workflowId));
540530
}
541531

542532
public Task<int> CancelWorkflowAsync(Guid workflowId, CancellationToken ct = default)
@@ -554,11 +544,7 @@ public Task<bool> TryNextCandidateAsync(Guid jobId, CancellationToken ct = defau
554544
public Task<bool> TryNextCandidateByDisplayIdAsync(int displayId, Guid? workflowId = null, CancellationToken ct = default)
555545
{
556546
ct.ThrowIfCancellationRequested();
557-
var job = engine.GetJob(displayId);
558-
if (job == null || (workflowId.HasValue && job.WorkflowId != workflowId.Value))
559-
return Task.FromResult(false);
560-
561-
return Task.FromResult(engine.TryNextCandidate(job.Id));
547+
return Task.FromResult(engine.TryNextCandidateByDisplayId(displayId, workflowId));
562548
}
563549

564550
private void Publish(string type, object payload)

Sockseek.Cli/Settings/CliSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Sockseek.Cli;
33
/// CLI-only settings — control presentation and UI behavior.
44
/// Not passed to the engine; consumed by the CLI layer before/when constructing the engine.
55
///
6-
/// The engine interacts with UI through EngineEvents only.
6+
/// The engine interacts with UI through Core event surfaces such as DownloadEvents and SearchEvents.
77
/// These settings tell the CLI which presentation/orchestration layers to wire up.
88
///
99
public class CliSettings

Sockseek.Cli/Utilities/JsonStreamProgressReporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public JsonStreamProgressReporter(TextWriter writer)
3131
};
3232
}
3333

34-
public void Attach(EngineEvents events)
34+
public void Attach(DownloadEvents events)
3535
{
3636
events.TrackListReady += songs => ReportTrackList(songs);
3737
events.JobStateChanged += job =>

0 commit comments

Comments
 (0)