mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-09 19:38:19 +02:00
Fix BaseWorker unnecessary nesting of Tasks
Some checks failed
Docker Image CI / build (push) Has been cancelled
Some checks failed
Docker Image CI / build (push) Has been cancelled
Fix MangaDex Oneshots have no Chapternumber
This commit is contained in:
@@ -324,7 +324,7 @@ public class MangaDex : MangaConnector
|
||||
{
|
||||
string? id = jToken.Value<string>("id");
|
||||
JToken? attributes = jToken["attributes"];
|
||||
string? chapterStr = attributes?.Value<string>("chapter");
|
||||
string? chapterStr = attributes?.Value<string>("chapter") ?? "0";
|
||||
string? volumeStr = attributes?.Value<string>("volume");
|
||||
int? volumeNumber = null;
|
||||
string? title = attributes?.Value<string>("title");
|
||||
|
@@ -73,24 +73,23 @@ public abstract class BaseWorker : Identifiable
|
||||
{
|
||||
// Start the worker
|
||||
Log.Debug($"Checking {this}");
|
||||
this._cancellationTokenSource = new(TimeSpan.FromMinutes(10));
|
||||
this.State = WorkerExecutionState.Waiting;
|
||||
_cancellationTokenSource = new(TimeSpan.FromMinutes(10));
|
||||
State = WorkerExecutionState.Waiting;
|
||||
|
||||
// Wait for dependencies, start them if necessary
|
||||
BaseWorker[] missingDependenciesThatNeedStarting = MissingDependencies.Where(d => d.State < WorkerExecutionState.Waiting).ToArray();
|
||||
if(missingDependenciesThatNeedStarting.Any())
|
||||
return new Task<BaseWorker[]>(() => missingDependenciesThatNeedStarting);
|
||||
return new (() => missingDependenciesThatNeedStarting);
|
||||
|
||||
if (MissingDependencies.Any())
|
||||
return new Task<BaseWorker[]>(WaitForDependencies);
|
||||
return new (WaitForDependencies);
|
||||
|
||||
// Run the actual work
|
||||
Log.Info($"Running {this}");
|
||||
DateTime startTime = DateTime.UtcNow;
|
||||
Task<BaseWorker[]> task = new Task<BaseWorker[]>(() => DoWorkInternal().Result);
|
||||
State = WorkerExecutionState.Running;
|
||||
Task<BaseWorker[]> task = DoWorkInternal();
|
||||
task.GetAwaiter().OnCompleted(Finish(startTime, callback));
|
||||
this.State = WorkerExecutionState.Running;
|
||||
task.Start();
|
||||
return task;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user