Moved notification back to DownloadChapterTask
temp: Dont wait for childTasks to finish to finish parent task
This commit is contained in:
parent
c97ff69148
commit
f9a7828d02
@ -77,34 +77,10 @@ public abstract class TrangaTask
|
|||||||
|
|
||||||
HttpStatusCode statusCode = ExecuteTask(taskManager, logger, cancellationToken);
|
HttpStatusCode statusCode = ExecuteTask(taskManager, logger, cancellationToken);
|
||||||
|
|
||||||
while(childTasks.Any(ct => ct.state is ExecutionState.Enqueued or ExecutionState.Running))
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
|
|
||||||
if((int)statusCode >= 200 && (int)statusCode < 300 && parentTask is null)
|
|
||||||
foreach(NotificationManager nm in taskManager.settings.notificationManagers)
|
|
||||||
switch (this.task)
|
|
||||||
{
|
|
||||||
case Task.MonitorPublication:
|
|
||||||
MonitorPublicationTask mpt = (MonitorPublicationTask)this;
|
|
||||||
int successfulCount = this.childTasks.Count(ct => ct.state is ExecutionState.Success);
|
|
||||||
if(successfulCount > 0)
|
|
||||||
nm.SendNotification("Downloaded new chapters", $"{mpt.publication.sortName}: {successfulCount} new chapters.");
|
|
||||||
break;
|
|
||||||
case Task.DownloadChapter:
|
|
||||||
DownloadChapterTask dct = (DownloadChapterTask)this;
|
|
||||||
nm.SendNotification("Chapter downloaded", $"{dct.publication.sortName} {dct.chapter.chapterNumber} {dct.chapter.name}");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ((int)statusCode >= 200 && (int)statusCode < 300)
|
if ((int)statusCode >= 200 && (int)statusCode < 300)
|
||||||
{
|
{
|
||||||
this.lastExecuted = DateTime.Now;
|
this.lastExecuted = DateTime.Now;
|
||||||
this.state = ExecutionState.Success;
|
this.state = ExecutionState.Success;
|
||||||
}else if (statusCode is HttpStatusCode.NotFound)
|
|
||||||
{
|
|
||||||
this.state = ExecutionState.Waiting;
|
|
||||||
this.lastExecuted = DateTime.MaxValue;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -112,8 +88,8 @@ public abstract class TrangaTask
|
|||||||
this.lastExecuted = DateTime.MaxValue;
|
this.lastExecuted = DateTime.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (TrangaTask childTask in this.childTasks.Where(ct => ct is DownloadChapterTask).ToArray())
|
if (this is DownloadChapterTask)
|
||||||
taskManager.DeleteTask(childTask);
|
taskManager.DeleteTask(this);
|
||||||
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Finished Executing Task {this}");
|
logger?.WriteLine(this.GetType().ToString(), $"Finished Executing Task {this}");
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ public class DownloadChapterTask : TrangaTask
|
|||||||
Connector connector = taskManager.GetConnector(this.connectorName);
|
Connector connector = taskManager.GetConnector(this.connectorName);
|
||||||
connector.CopyCoverFromCacheToDownloadLocation(this.publication, taskManager.settings);
|
connector.CopyCoverFromCacheToDownloadLocation(this.publication, taskManager.settings);
|
||||||
HttpStatusCode downloadSuccess = connector.DownloadChapter(this.publication, this.chapter, this, cancellationToken);
|
HttpStatusCode downloadSuccess = connector.DownloadChapter(this.publication, this.chapter, this, cancellationToken);
|
||||||
|
if((int)downloadSuccess >= 200 && (int)downloadSuccess < 300)
|
||||||
|
foreach(NotificationManager nm in taskManager.settings.notificationManagers)
|
||||||
|
nm.SendNotification("Chapter downloaded", $"{this.publication.sortName} {this.chapter.chapterNumber} {this.chapter.name}");
|
||||||
return downloadSuccess;
|
return downloadSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user