Skip to content

Commit

Permalink
Move the library watcher off to a background thread to not block main…
Browse files Browse the repository at this point in the history
… thread when users have massive libraries.

Fixed up a render issue for volumes with unique names in LN/Book libraries and prioritizeTitle as true.
  • Loading branch information
majora2007 committed Aug 20, 2024
1 parent 2ad7101 commit b2e91b2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion API/Services/HostedServices/StartupTasksHostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using API.Data;
using API.Services.Tasks.Scanner;
using Hangfire;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Expand Down Expand Up @@ -45,7 +46,8 @@ public async Task StartAsync(CancellationToken cancellationToken)
if ((await unitOfWork.SettingsRepository.GetSettingsDtoAsync()).EnableFolderWatching)
{
var libraryWatcher = scope.ServiceProvider.GetRequiredService<ILibraryWatcher>();
await libraryWatcher.StartWatching();
// Push this off for a bit for people with massive libraries, as it can take up to 45 mins and blocks the thread
BackgroundJob.Enqueue(() => libraryWatcher.StartWatching());
}
}
catch (Exception)
Expand Down
12 changes: 10 additions & 2 deletions UI/Web/src/app/cards/entity-title/entity-title.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@
}

@case (LibraryType.Book) {
{{volumeTitle}}
@if (titleName !== '' && prioritizeTitleName) {
{{titleName}}
} @else {
{{volumeTitle}}
}
}

@case (LibraryType.LightNovel) {
{{volumeTitle}}
@if (titleName !== '' && prioritizeTitleName) {
{{titleName}}
} @else {
{{volumeTitle}}
}
}

@case (LibraryType.Images) {
Expand Down
2 changes: 1 addition & 1 deletion UI/Web/src/app/volume-detail/volume-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4 class="title mb-2">
<div class="subtitle mt-2 mb-2">
<span>
{{t('volume-num')}}
<app-entity-title [libraryType]="libraryType!" [entity]="volume" [prioritizeTitleName]="true"></app-entity-title>
<app-entity-title [libraryType]="libraryType" [entity]="volume" [prioritizeTitleName]="true"></app-entity-title>
</span>
</div>

Expand Down

0 comments on commit b2e91b2

Please sign in to comment.