mirror of
https://github.com/Radarr/Radarr
synced 2026-01-24 08:23:54 +01:00
Fix blocking semaphore in MediaCoverService
Convert _semaphore.Wait() to async pattern with WaitAsync() to prevent thread blocking during image resizing operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f435f38a27
commit
e2b2227a17
1 changed files with 5 additions and 4 deletions
|
|
@ -4,6 +4,7 @@
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Disk;
|
||||
|
|
@ -141,7 +142,7 @@ private string GetMovieCoverPath(int movieId)
|
|||
return Path.Combine(_coverRootFolder, movieId.ToString());
|
||||
}
|
||||
|
||||
private bool EnsureCovers(Movie movie)
|
||||
private async Task<bool> EnsureCoversAsync(Movie movie)
|
||||
{
|
||||
var updated = false;
|
||||
var toResize = new List<Tuple<MediaCover, bool>>();
|
||||
|
|
@ -184,7 +185,7 @@ private bool EnsureCovers(Movie movie)
|
|||
|
||||
try
|
||||
{
|
||||
_semaphore.Wait();
|
||||
await _semaphore.WaitAsync();
|
||||
|
||||
foreach (var tuple in toResize)
|
||||
{
|
||||
|
|
@ -261,9 +262,9 @@ private static string GetExtension(MediaCoverTypes coverType)
|
|||
};
|
||||
}
|
||||
|
||||
public void HandleAsync(MovieUpdatedEvent message)
|
||||
public async void HandleAsync(MovieUpdatedEvent message)
|
||||
{
|
||||
var updated = EnsureCovers(message.Movie);
|
||||
var updated = await EnsureCoversAsync(message.Movie);
|
||||
|
||||
_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie, updated));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue