more better exception handling.
This commit is contained in:
parent
2e174c03c9
commit
6af98f9e96
|
@ -1496,11 +1496,19 @@ namespace NzbDrone.Core.Test
|
||||||
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
|
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId), postDownloadStatus);
|
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
var result = db.Fetch<Episode>();
|
var result = db.Fetch<Episode>();
|
||||||
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(episodeCount);
|
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(episodeCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[ExpectedException(typeof(ArgumentException))]
|
||||||
|
public void SetPostDownloadStatus_should_throw_if_episode_list_is_empty()
|
||||||
|
{
|
||||||
|
var mocker = new AutoMoqer();
|
||||||
|
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(new List<int>(), PostDownloadStatusType.Failed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,6 +16,8 @@ namespace NzbDrone.Core.Instrumentation
|
||||||
|
|
||||||
Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName);
|
Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName);
|
||||||
|
|
||||||
|
logEvent.Exception.Data.Add("Message", logEvent.Message);
|
||||||
|
|
||||||
new Client
|
new Client
|
||||||
{
|
{
|
||||||
ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265",
|
ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265",
|
||||||
|
|
|
@ -397,8 +397,10 @@ namespace NzbDrone.Core.Providers
|
||||||
Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId);
|
Logger.Trace("Finished deleting invalid episodes for {0}", series.SeriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetPostDownloadStatus(IEnumerable<int> episodeIds, PostDownloadStatusType postDownloadStatus)
|
public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus)
|
||||||
{
|
{
|
||||||
|
if (episodeIds.Count == 0) throw new ArgumentException("episodeIds should contain one or more episode ids.");
|
||||||
|
|
||||||
var episodeIdString = String.Join(", ", episodeIds);
|
var episodeIdString = String.Join(", ", episodeIds);
|
||||||
|
|
||||||
var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
|
var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using NLog;
|
using NLog;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using NzbDrone.Core.Model;
|
using NzbDrone.Core.Model;
|
||||||
|
@ -171,7 +170,9 @@ namespace NzbDrone.Core.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add to InfoList for possible later processing
|
//Add to InfoList for possible later processing
|
||||||
InfoList.Add(new PostDownloadInfoModel{ Name = directoryInfo.FullName,
|
InfoList.Add(new PostDownloadInfoModel
|
||||||
|
{
|
||||||
|
Name = directoryInfo.FullName,
|
||||||
Added = DateTime.Now,
|
Added = DateTime.Now,
|
||||||
Status = postDownloadStatus
|
Status = postDownloadStatus
|
||||||
});
|
});
|
||||||
|
@ -180,15 +181,18 @@ namespace NzbDrone.Core.Providers
|
||||||
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(8));
|
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(8));
|
||||||
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
|
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
|
||||||
|
|
||||||
var episodeIds = new List<int>();
|
List<int> episodeIds;
|
||||||
|
|
||||||
if (parseResult.EpisodeNumbers.Count == 0 && parseResult.FullSeason)
|
if (parseResult.EpisodeNumbers.Count == 0 && parseResult.FullSeason)
|
||||||
|
{
|
||||||
episodeIds =
|
episodeIds =
|
||||||
_episodeProvider.GetEpisodesBySeason(parseResult.Series.SeriesId, parseResult.SeasonNumber)
|
_episodeProvider.GetEpisodesBySeason(parseResult.Series.SeriesId, parseResult.SeasonNumber)
|
||||||
.Select(e => e.EpisodeId).ToList();
|
.Select(e => e.EpisodeId).ToList();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
episodeIds = _episodeProvider.GetEpisodesByParseResult(parseResult).Select(e => e.EpisodeId).ToList();
|
episodeIds = _episodeProvider.GetEpisodesByParseResult(parseResult).Select(e => e.EpisodeId).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
_episodeProvider.SetPostDownloadStatus(episodeIds, postDownloadStatus);
|
_episodeProvider.SetPostDownloadStatus(episodeIds, postDownloadStatus);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue