mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-11 13:19:48 +02:00
Add RefreshLibrariesWorker.cs
This commit is contained in:
29
API/Workers/RefreshLibrariesWorker.cs
Normal file
29
API/Workers/RefreshLibrariesWorker.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using API.Schema.LibraryContext;
|
||||
using API.Schema.LibraryContext.LibraryConnectors;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Workers;
|
||||
|
||||
public class RefreshLibrariesWorker(IEnumerable<BaseWorker>? dependsOn = null) : BaseWorkerWithContext<LibraryContext>(dependsOn)
|
||||
{
|
||||
public static DateTime LastRefresh { get; set; } = DateTime.UnixEpoch;
|
||||
|
||||
protected override async Task<BaseWorker[]> DoWorkInternal()
|
||||
{
|
||||
Log.Debug("Refreshing libraries...");
|
||||
LastRefresh = DateTime.UtcNow;
|
||||
List<LibraryConnector> libraries = await DbContext.LibraryConnectors.ToListAsync(CancellationToken);
|
||||
foreach (LibraryConnector connector in libraries)
|
||||
await connector.UpdateLibrary(CancellationToken);
|
||||
Log.Debug("Libraries Refreshed...");
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public enum LibraryRefreshSetting : byte
|
||||
{
|
||||
AfterAllFinished = 0,
|
||||
AfterMangaFinished = 1,
|
||||
AfterEveryChapter = 2,
|
||||
WhileDownloading = 3
|
||||
}
|
Reference in New Issue
Block a user