diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 5ba34fb83..4942c1191 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -132,6 +132,7 @@ private static void BindJobs() _kernel.Bind().To().InTransientScope(); _kernel.Bind().To().InTransientScope(); _kernel.Bind().To().InTransientScope(); + _kernel.Bind().To().InTransientScope(); _kernel.Get().Initialize(); _kernel.Get().StartTimer(30); diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index fa1485f44..103ab582f 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -171,6 +171,7 @@ + diff --git a/NzbDrone.Core/Providers/Jobs/MediaFileScanJob.cs b/NzbDrone.Core/Providers/Jobs/MediaFileScanJob.cs new file mode 100644 index 000000000..de757c6fb --- /dev/null +++ b/NzbDrone.Core/Providers/Jobs/MediaFileScanJob.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NzbDrone.Core.Model.Notification; +using NzbDrone.Core.Repository; + +namespace NzbDrone.Core.Providers.Jobs +{ + public class MediaFileScanJob : IJob + { + private readonly SeriesProvider _seriesProvider; + private readonly MediaFileProvider _mediaFileProvider; + + public MediaFileScanJob(SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider) + { + _seriesProvider = seriesProvider; + _mediaFileProvider = mediaFileProvider; + } + + public string Name + { + get { return "Media File Scan"; } + } + + public int DefaultInterval + { + get { return 60; } + } + + public void Start(ProgressNotification notification, int targetId) + { + IList seriesToScan; + if (targetId == 0) + { + seriesToScan = _seriesProvider.GetAllSeries().ToList(); + } + else + { + seriesToScan = new List() { _seriesProvider.GetSeries(targetId) }; + } + + foreach (var series in seriesToScan) + { + notification.CurrentMessage = "Scanning for files: " + series.Title; + _mediaFileProvider.Scan(series); + notification.CurrentMessage = "Media File Scan completed for " + series.Title; + } + } + } +}