Implement #445, Startup tasks

This commit is contained in:
2025-09-21 18:09:37 +02:00
parent 3a21517a18
commit 5c29496fa5
4 changed files with 17 additions and 29 deletions

View File

@@ -32,7 +32,6 @@ public static class Tranga
internal static readonly StartNewChapterDownloadsWorker StartNewChapterDownloadsWorker = new();
internal static readonly RemoveOldNotificationsWorker RemoveOldNotificationsWorker = new();
internal static readonly UpdateCoversWorker UpdateCoversWorker = new();
internal static readonly UpdateLibraryConnectorsWorker UpdateLibraryConnectorsWorker = new();
internal static readonly CleanupMangaconnectorIdsWithoutConnector CleanupMangaconnectorIdsWithoutConnector = new();
// ReSharper restore MemberCanBePrivate.Global
@@ -43,18 +42,25 @@ public static class Tranga
Log.Info(Constants.TRANGA);
}
internal static void StartupTasks()
{
AddWorker(SendNotificationsWorker);
AddWorker(CleanupMangaconnectorIdsWithoutConnector);
AddWorker(UpdateChaptersDownloadedWorker);
AddWorker(CleanupMangaCoversWorker);
Log.Info("Waiting for startup to complete...");
while (new List<BaseWorker>() { CleanupMangaconnectorIdsWithoutConnector, UpdateChaptersDownloadedWorker, CleanupMangaCoversWorker}.Any(w => w.State < WorkerExecutionState.Completed))
Thread.Sleep(100);
Log.Info("Start complete!");
}
internal static void AddDefaultWorkers()
{
AddWorker(UpdateMetadataWorker);
AddWorker(SendNotificationsWorker);
AddWorker(UpdateChaptersDownloadedWorker);
AddWorker(CheckForNewChaptersWorker);
AddWorker(CleanupMangaCoversWorker);
AddWorker(StartNewChapterDownloadsWorker);
AddWorker(RemoveOldNotificationsWorker);
AddWorker(UpdateCoversWorker);
AddWorker(UpdateLibraryConnectorsWorker);
AddWorker(CleanupMangaconnectorIdsWithoutConnector);
}
internal static bool TryGetMangaConnector(string name, [NotNullWhen(true)]out MangaConnector? mangaConnector)