@ -4,7 +4,6 @@ using System.Linq;
using System.Threading.Tasks ;
using NLog ;
using NzbDrone.Common.Instrumentation.Extensions ;
using NzbDrone.Common.TPL ;
using NzbDrone.Core.ImportLists.ImportListMovies ;
using NzbDrone.Core.MetadataSource ;
using NzbDrone.Core.Movies ;
@ -23,7 +22,6 @@ namespace NzbDrone.Core.ImportLists
private readonly IImportListStatusService _importListStatusService ;
private readonly IImportListMovieService _listMovieService ;
private readonly ISearchForNewMovie _movieSearch ;
private readonly IProvideMovieInfo _movieInfoService ;
private readonly IMovieMetadataService _movieMetadataService ;
private readonly Logger _logger ;
@ -31,7 +29,6 @@ namespace NzbDrone.Core.ImportLists
IImportListStatusService importListStatusService ,
IImportListMovieService listMovieService ,
ISearchForNewMovie movieSearch ,
IProvideMovieInfo movieInfoService ,
IMovieMetadataService movieMetadataService ,
Logger logger )
{
@ -39,7 +36,6 @@ namespace NzbDrone.Core.ImportLists
_importListStatusService = importListStatusService ;
_listMovieService = listMovieService ;
_movieSearch = movieSearch ;
_movieInfoService = movieInfoService ;
_movieMetadataService = movieMetadataService ;
_logger = logger ;
}
@ -58,10 +54,7 @@ namespace NzbDrone.Core.ImportLists
_logger . Debug ( "Available import lists {0}" , importLists . Count ) ;
var taskList = new List < Task > ( ) ;
var taskFactory = new TaskFactory ( TaskCreationOptions . LongRunning , TaskContinuationOptions . None ) ;
foreach ( var importList in importLists )
Parallel . ForEach ( importLists , new ParallelOptions { MaxDegreeOfParallelism = 5 } , importList = >
{
var importListLocal = importList ;
var importListStatus = _importListStatusService . GetLastSyncListInfo ( importListLocal . Definition . Id ) ;
@ -74,7 +67,7 @@ namespace NzbDrone.Core.ImportLists
{
_logger . Trace ( "Skipping refresh of Import List {0} ({1}) due to minimum refresh interval. Next Sync after {2}" , importList . Name , importListLocal . Definition . Name , importListNextSync ) ;
continue ;
return ;
}
}
@ -86,11 +79,9 @@ namespace NzbDrone.Core.ImportLists
{
_logger . Debug ( "Temporarily ignoring Import List {0} ({1}) till {2} due to recent failures." , importList . Name , importListLocal . Definition . Name , blockedListStatus . DisabledTill . Value . ToLocalTime ( ) ) ;
result . AnyFailure | = true ; // Ensure we don't clean if a list is down
continue ;
return ;
}
var task = taskFactory . StartNew ( ( ) = >
{
try
{
var importListReports = importListLocal . Fetch ( ) ;
@ -122,12 +113,7 @@ namespace NzbDrone.Core.ImportLists
{
_logger . Error ( e , "Error during Import List Sync of {0} ({1})" , importList . Name , importListLocal . Definition . Name ) ;
}
} ) . LogExceptions ( ) ;
taskList . Add ( task ) ;
}
Task . WaitAll ( taskList . ToArray ( ) ) ;
} ) ;
result . Movies = result . Movies . DistinctBy ( r = > new { r . TmdbId , r . ImdbId , r . Title } ) . ToList ( ) ;