failed disk scan doesn't kill the whole job anymore
This commit is contained in:
parent
ce63f05512
commit
f3be5fa08e
|
@ -1,4 +1,5 @@
|
|||
// ReSharper disable RedundantUsingDirective
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
@ -95,6 +96,36 @@ namespace NzbDrone.Core.Test
|
|||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void failed_scan_should_not_terminated_job()
|
||||
{
|
||||
var series = Builder<Series>.CreateListOfSize(2)
|
||||
.WhereTheFirst(1).Has(s => s.SeriesId = 12)
|
||||
.AndTheNext(1).Has(s => s.SeriesId = 15)
|
||||
.WhereAll().Have(s => s.Episodes = Builder<Episode>.CreateListOfSize(10).Build())
|
||||
.Build();
|
||||
|
||||
var mocker = new AutoMoqer(MockBehavior.Strict);
|
||||
|
||||
mocker.GetMock<SeriesProvider>()
|
||||
.Setup(p => p.GetAllSeries())
|
||||
.Returns(series.AsQueryable());
|
||||
|
||||
mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.Scan(series[0]))
|
||||
.Throws(new InvalidOperationException("Bad Job"));
|
||||
|
||||
mocker.GetMock<MediaFileProvider>()
|
||||
.Setup(s => s.Scan(series[1]))
|
||||
.Throws(new InvalidOperationException("Bad Job"));
|
||||
|
||||
mocker.Resolve<DiskScanJob>().Start(new ProgressNotification("Test"), 0);
|
||||
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
ExceptionVerification.ExcpectedErrors(2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void job_with_no_target_should_scan_series_with_episodes()
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Model.Notification;
|
||||
using NzbDrone.Core.Repository;
|
||||
|
||||
|
@ -11,6 +12,7 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
{
|
||||
private readonly SeriesProvider _seriesProvider;
|
||||
private readonly MediaFileProvider _mediaFileProvider;
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public DiskScanJob(SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider)
|
||||
{
|
||||
|
@ -46,9 +48,16 @@ namespace NzbDrone.Core.Providers.Jobs
|
|||
|
||||
foreach (var series in seriesToScan.Where(c => c.Episodes.Count != 0))
|
||||
{
|
||||
notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title);
|
||||
_mediaFileProvider.Scan(series);
|
||||
notification.CurrentMessage = string.Format("Media File Scan completed for '{0}'", series.Title);
|
||||
try
|
||||
{
|
||||
notification.CurrentMessage = string.Format("Scanning disk for '{0}'", series.Title);
|
||||
_mediaFileProvider.Scan(series);
|
||||
notification.CurrentMessage = string.Format("Media File Scan completed for '{0}'", series.Title);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorException("An error has occured while scanning " + series.Title, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue