mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
parent
a7aff3bd9a
commit
13f540f1f5
@ -1,11 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FizzWare.NBuilder;
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
using Moq;
|
using Moq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Exceptions;
|
using NzbDrone.Core.Exceptions;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
using NzbDrone.Core.MetadataSource;
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.Test.Framework;
|
using NzbDrone.Core.Test.Framework;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
@ -180,5 +183,35 @@ public void should_filter_duplicate_seasons()
|
|||||||
.Verify(v => v.UpdateSeries(It.Is<Series>(s => s.Seasons.Count == 2), It.IsAny<bool>()));
|
.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.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -144,6 +144,18 @@ private List<Season> UpdateSeasons(Series series, Series seriesInfo)
|
|||||||
return seasons;
|
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)
|
public void Execute(RefreshSeriesCommand message)
|
||||||
{
|
{
|
||||||
_eventAggregator.PublishEvent(new SeriesRefreshStartingEvent(message.Trigger == CommandTrigger.Manual));
|
_eventAggregator.PublishEvent(new SeriesRefreshStartingEvent(message.Trigger == CommandTrigger.Manual));
|
||||||
@ -151,8 +163,18 @@ public void Execute(RefreshSeriesCommand message)
|
|||||||
if (message.SeriesId.HasValue)
|
if (message.SeriesId.HasValue)
|
||||||
{
|
{
|
||||||
var series = _seriesService.GetSeries(message.SeriesId.Value);
|
var series = _seriesService.GetSeries(message.SeriesId.Value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
RefreshSeriesInfo(series);
|
RefreshSeriesInfo(series);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Error(e, "Couldn't refresh info for {0}", series);
|
||||||
|
RescanSeries(series);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.SortTitle).ToList();
|
var allSeries = _seriesService.GetAllSeries().OrderBy(c => c.SortTitle).ToList();
|
||||||
@ -168,20 +190,14 @@ public void Execute(RefreshSeriesCommand message)
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "Couldn't refresh info for {0}", series);
|
_logger.Error(e, "Couldn't refresh info for {0}", series);
|
||||||
|
RescanSeries(series);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
_logger.Info("Skipping refresh of series: {0}", series.Title);
|
_logger.Info("Skipping refresh of series: {0}", series.Title);
|
||||||
_diskScanService.Scan(series);
|
RescanSeries(series);
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_logger.Error(e, "Couldn't rescan series {0}", series);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user