mirror of
https://github.com/C9Glax/tranga.git
synced 2025-09-10 03:48:19 +02:00
Fix new Workers not getting added.
This commit is contained in:
@@ -145,6 +145,12 @@ public static class Tranga
|
|||||||
private static Action AfterWork(BaseWorker worker, Action? callback = null) => () =>
|
private static Action AfterWork(BaseWorker worker, Action? callback = null) => () =>
|
||||||
{
|
{
|
||||||
Log.Debug($"AfterWork {worker}");
|
Log.Debug($"AfterWork {worker}");
|
||||||
|
if (RunningWorkers.TryGetValue(worker, out Task<BaseWorker[]>? task))
|
||||||
|
{
|
||||||
|
BaseWorker[] newWorkers = task.Result;
|
||||||
|
Log.Debug($"Resulted in {newWorkers.Length} new Workers.");
|
||||||
|
AddWorkers(newWorkers);
|
||||||
|
}
|
||||||
RunningWorkers.Remove(worker, out _);
|
RunningWorkers.Remove(worker, out _);
|
||||||
callback?.Invoke();
|
callback?.Invoke();
|
||||||
};
|
};
|
||||||
|
@@ -14,12 +14,16 @@ public class StartNewChapterDownloadsWorker(TimeSpan? interval = null, IEnumerab
|
|||||||
public TimeSpan Interval { get; set; } = interval ?? TimeSpan.FromMinutes(1);
|
public TimeSpan Interval { get; set; } = interval ?? TimeSpan.FromMinutes(1);
|
||||||
protected override async Task<BaseWorker[]> DoWorkInternal()
|
protected override async Task<BaseWorker[]> DoWorkInternal()
|
||||||
{
|
{
|
||||||
|
Log.Debug("Checking for missing chapters...");
|
||||||
|
|
||||||
// Get missing chapters
|
// Get missing chapters
|
||||||
List<MangaConnectorId<Chapter>> missingChapters = await DbContext.MangaConnectorToChapter
|
List<MangaConnectorId<Chapter>> missingChapters = await DbContext.MangaConnectorToChapter
|
||||||
.Include(id => id.Obj)
|
.Include(id => id.Obj)
|
||||||
.Where(id => id.Obj.Downloaded == false && id.UseForDownload)
|
.Where(id => id.Obj.Downloaded == false && id.UseForDownload)
|
||||||
.ToListAsync(CancellationToken);
|
.ToListAsync(CancellationToken);
|
||||||
|
|
||||||
|
Log.Debug($"Found {missingChapters.Count} missing downloads.");
|
||||||
|
|
||||||
// Create new jobs
|
// Create new jobs
|
||||||
List<BaseWorker> newWorkers = missingChapters.Select(mcId => new DownloadChapterFromMangaconnectorWorker(mcId)).ToList<BaseWorker>();
|
List<BaseWorker> newWorkers = missingChapters.Select(mcId => new DownloadChapterFromMangaconnectorWorker(mcId)).ToList<BaseWorker>();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user