1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-20 18:02:44 +01:00

Fixed: MediaCovers resizing potentially leaking memory when concurrently executing.

This commit is contained in:
Leonardo Galli 2018-12-14 09:55:14 +01:00
parent 899bd086ec
commit fed4a0aebe
4 changed files with 43 additions and 6 deletions

2
.gitignore vendored
View File

@ -104,7 +104,7 @@ _TeamCity*
# Radarr
Backups/
logs/
MediaCover/
#MediaCover/
UpdateLogs/
xdg/
config.xml

View File

@ -0,0 +1,19 @@
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Core.MediaCover
{
public class EnsureMediaCoversCommand : Command
{
public int MovieId { get; set; }
public EnsureMediaCoversCommand()
{
}
public EnsureMediaCoversCommand(int movieId)
{
MovieId = movieId;
}
}
}

View File

@ -8,6 +8,7 @@
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Movies.Events;
@ -24,6 +25,7 @@ public class MediaCoverService :
IHandleAsync<MovieUpdatedEvent>,
IHandleAsync<MovieAddedEvent>,
IHandleAsync<MovieDeletedEvent>,
IExecute<EnsureMediaCoversCommand>,
IMapCoversToLocal
{
private readonly IImageResizer _resizer;
@ -32,6 +34,8 @@ public class MediaCoverService :
private readonly ICoverExistsSpecification _coverExistsSpecification;
private readonly IConfigFileProvider _configFileProvider;
private readonly IEventAggregator _eventAggregator;
private readonly IManageCommandQueue _commandQueue;
private readonly IMovieService _movieService;
private readonly Logger _logger;
private readonly string _coverRootFolder;
@ -43,6 +47,8 @@ public MediaCoverService(IImageResizer resizer,
ICoverExistsSpecification coverExistsSpecification,
IConfigFileProvider configFileProvider,
IEventAggregator eventAggregator,
IManageCommandQueue commandQueue,
IMovieService movieService,
Logger logger)
{
_resizer = resizer;
@ -51,6 +57,8 @@ public MediaCoverService(IImageResizer resizer,
_coverExistsSpecification = coverExistsSpecification;
_configFileProvider = configFileProvider;
_eventAggregator = eventAggregator;
_commandQueue = commandQueue;
_movieService = movieService;
_logger = logger;
_coverRootFolder = appFolderInfo.GetMediaCoverPath();
@ -182,16 +190,25 @@ private void EnsureResizedCovers(Movie movie, MediaCover cover, bool forceResize
}
}
public void Execute(EnsureMediaCoversCommand command)
{
var movie = _movieService.GetMovie(command.MovieId);
EnsureCovers(movie);
_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(movie));
}
public void HandleAsync(MovieUpdatedEvent message)
{
EnsureCovers(message.Movie);
_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie));
//EnsureCovers(message.Movie);
_commandQueue.Push(new EnsureMediaCoversCommand(message.Movie.Id));
//_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie));
}
public void HandleAsync(MovieAddedEvent message)
{
EnsureCovers(message.Movie);
_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie));
//EnsureCovers(message.Movie);
_commandQueue.Push(new EnsureMediaCoversCommand(message.Movie.Id));
//_eventAggregator.PublishEvent(new MediaCoversUpdatedEvent(message.Movie));
}
public void HandleAsync(MovieDeletedEvent message)

View File

@ -152,6 +152,7 @@
<Compile Include="Extras\Metadata\Consumers\Xbmc\XbmcNfoDetector.cs" />
<Compile Include="Extras\Others\OtherExtraFileRenamer.cs" />
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedAlternativeTitles.cs" />
<Compile Include="MediaCover\EnsureMediaCoversCommand.cs" />
<Compile Include="MediaFiles\Commands\UpdateMovieFileQualityCommand.cs" />
<Compile Include="MediaFiles\MovieImport\Specifications\GrabbedReleaseQualitySpecification.cs" />
<Compile Include="MediaFiles\MovieImport\Specifications\SameFileSpecification.cs" />
@ -1326,4 +1327,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>