mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-11 13:19:48 +02:00
WhileDownloading also refresh after all downloads are finished
This commit is contained in:
@@ -139,18 +139,21 @@ public class DownloadChapterFromMangaconnectorWorker(MangaConnectorId<Chapter> c
|
||||
Log.Debug($"Downloaded chapter {chapter}.");
|
||||
|
||||
bool refreshLibrary = await CheckLibraryRefresh();
|
||||
if(refreshLibrary)
|
||||
Log.Info($"Condition {Tranga.Settings.LibraryRefreshSetting} met.");
|
||||
|
||||
return refreshLibrary? [new RefreshLibrariesWorker()] : [];
|
||||
}
|
||||
|
||||
private async Task<bool> CheckLibraryRefresh() => Tranga.Settings.LibraryRefreshSetting switch
|
||||
{
|
||||
LibraryRefreshSetting.AfterAllFinished => (await StartNewChapterDownloadsWorker.GetMissingChapters(DbContext, CancellationToken)).Count == 0,
|
||||
LibraryRefreshSetting.AfterAllFinished => await AllDownloadsFinished(),
|
||||
LibraryRefreshSetting.AfterMangaFinished => await DbContext.MangaConnectorToChapter.Include(chId => chId.Obj).Where(chId => chId.UseForDownload).AllAsync(chId => chId.Obj.Downloaded, CancellationToken),
|
||||
LibraryRefreshSetting.AfterEveryChapter => true,
|
||||
LibraryRefreshSetting.WhileDownloading => DateTime.UtcNow.Subtract(RefreshLibrariesWorker.LastRefresh).TotalMinutes > Tranga.Settings.RefreshLibraryWhileDownloadingEveryMinutes,
|
||||
LibraryRefreshSetting.WhileDownloading => await AllDownloadsFinished() || DateTime.UtcNow.Subtract(RefreshLibrariesWorker.LastRefresh).TotalMinutes > Tranga.Settings.RefreshLibraryWhileDownloadingEveryMinutes,
|
||||
_ => true
|
||||
};
|
||||
private async Task<bool> AllDownloadsFinished() => (await StartNewChapterDownloadsWorker.GetMissingChapters(DbContext, CancellationToken)).Count == 0;
|
||||
|
||||
private void ProcessImage(string imagePath)
|
||||
{
|
||||
|
Reference in New Issue
Block a user