mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-27 18:28:19 +00:00
parent
a7aff3bd9a
commit
13f540f1f5
2 changed files with 61 additions and 12 deletions
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FizzWare.NBuilder;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.MediaFiles;
|
||||
using NzbDrone.Core.MetadataSource;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
@ -180,5 +183,35 @@ namespace NzbDrone.Core.Test.TvTests
|
|||
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2), It.IsAny<bool>()));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_rescan_series_if_updating_fails()
|
||||
{
|
||||
Mocker.GetMock<IProvideSeriesInfo>()
|
||||
.Setup(s => s.GetSeriesInfo(_series.Id))
|
||||
.Throws(new IOException());
|
||||
|
||||
Assert.Throws<IOException>(() => Subject.Execute(new RefreshSeriesCommand(_series.Id)));
|
||||
|
||||
Mocker.GetMock<IDiskScanService>()
|
||||
.Verify(v => v.Scan(_series), Times.Once());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_not_rescan_series_if_updating_fails_with_series_not_found()
|
||||
{
|
||||
Mocker.GetMock<IProvideSeriesInfo>()
|
||||
.Setup(s => s.GetSeriesInfo(_series.Id))
|
||||
.Throws(new SeriesNotFoundException(_series.Id));
|
||||
|
||||
Subject.Execute(new RefreshSeriesCommand(_series.Id));
|
||||
|
||||
Mocker.GetMock<IDiskScanService>()
|
||||
.Verify(v => v.Scan(_series), Times.Never());
|
||||
|
||||
ExceptionVerification.ExpectedErrors(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -144,6 +144,18 @@ namespace NzbDrone.Core.Tv
|
|||
return seasons;
|
||||
}
|
||||
|
||||
private void RescanSeries(Series series)
|
||||
{
|
||||
try
|
||||
{
|
||||
_diskScanService.Scan(series);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't rescan series {0}", series);
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(RefreshSeriesCommand message)
|
||||
{
|
||||
_eventAggregator.PublishEvent(new SeriesRefreshStartingEvent(message.Trigger == CommandTrigger.Manual));
|
||||
|
@ -151,7 +163,17 @@ namespace NzbDrone.Core.Tv
|
|||
if (message.SeriesId.HasValue)
|
||||
{
|
||||
var series = _seriesService.GetSeries(message.SeriesId.Value);
|
||||
RefreshSeriesInfo(series);
|
||||
|
||||
try
|
||||
{
|
||||
RefreshSeriesInfo(series);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't refresh info for {0}", series);
|
||||
RescanSeries(series);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -168,20 +190,14 @@ namespace NzbDrone.Core.Tv
|
|||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't refresh info for {0}", series);
|
||||
RescanSeries(series);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.Info("Skipping refresh of series: {0}", series.Title);
|
||||
_diskScanService.Scan(series);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't rescan series {0}", series);
|
||||
}
|
||||
_logger.Info("Skipping refresh of series: {0}", series.Title);
|
||||
RescanSeries(series);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue