1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Merge branch 'kay.one' of github.com:NzbDrone/NzbDrone into markus

Conflicts:
	NzbDrone.Core.Test/EpisodeProviderTest.cs
	NzbDrone.Core/Providers/PostDownloadProvider.cs
This commit is contained in:
Mark McDowall 2011-10-17 15:30:43 -07:00
commit 66b4b094f9
5 changed files with 70 additions and 18 deletions

View File

@ -63,7 +63,7 @@ public void GetEpisodes_by_season_episode_exists()
db.Insert(fakeSeries);
db.Insert(fakeEpisodes);
//Act
var episode = mocker.Resolve<EpisodeProvider>().GetEpisode(fakeSeries.SeriesId, 2, 1);
@ -453,8 +453,8 @@ public void should_try_to_get_existing_episode_using_tvdbid_first()
.Build();
var fakeSeries = Builder<Series>.CreateNew().With(c => c.SeriesId = seriesId).Build();
var fakeEpisodeList = new List<Episode> { new Episode { TvDbEpisodeId = 99, SeasonNumber = 10, EpisodeNumber = 10, Series = fakeSeries} };
var fakeEpisodeList = new List<Episode> { new Episode { TvDbEpisodeId = 99, SeasonNumber = 10, EpisodeNumber = 10, Series = fakeSeries } };
var mocker = new AutoMoqer();
mocker.GetMock<IDatabase>()
.Setup(d => d.Fetch<Episode, Series, EpisodeFile>(It.IsAny<String>(), It.IsAny<Object[]>()))
@ -512,7 +512,7 @@ public void should_try_to_get_existing_episode_using_tvdbid_first_then_season_ep
//Assert
mocker.VerifyAllMocks();
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(new List<Episode>{localEpisode}), Times.Once());
mocker.GetMock<IDatabase>().Verify(c => c.UpdateMany(new List<Episode> { localEpisode }), Times.Once());
}
[Test]
@ -528,7 +528,7 @@ public void existing_episodes_keep_their_episodeId_file_id()
var currentEpisodes = new List<Episode>();
foreach (var tvDbEpisode in tvdbSeries.Episodes)
{
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id, EpisodeId = 99, EpisodeFileId = 69, Ignored = true, Series = fakeSeries});
currentEpisodes.Add(new Episode { TvDbEpisodeId = tvDbEpisode.Id, EpisodeId = 99, EpisodeFileId = 69, Ignored = true, Series = fakeSeries });
}
var mocker = new AutoMoqer();
@ -545,7 +545,7 @@ public void existing_episodes_keep_their_episodeId_file_id()
mocker.GetMock<IDatabase>()
.Setup(c => c.UpdateMany(It.IsAny<IEnumerable<Episode>>()))
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes =ep.ToList());
.Callback<IEnumerable<Episode>>(ep => updatedEpisodes = ep.ToList());
//Act
mocker.Resolve<EpisodeProvider>().RefreshEpisodeInfo(fakeSeries);
@ -1497,7 +1497,7 @@ public void SetPostDownloadStatus(string folderName, PostDownloadStatusType post
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
//Act
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId), postDownloadStatus);
mocker.Resolve<EpisodeProvider>().SetPostDownloadStatus(fakeEpisodes.Select(e => e.EpisodeId).ToList(), postDownloadStatus);
//Assert
var result = db.Fetch<Episode>();
@ -1572,5 +1572,11 @@ public void SetPostDownloadStatus_No_EpisodeId_In_Database()
var result = db.Fetch<Episode>();
result.Where(e => e.PostDownloadStatus == postDownloadStatus).Count().Should().Be(0);
}
[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);
}
}
}
}

View File

@ -13,9 +13,11 @@ protected override void Write(LogEventInfo logEvent)
{
if (logEvent == null || logEvent.Exception == null) return;
if (Debugger.IsAttached || Process.GetCurrentProcess().ProcessName.Contains("JetBrains")) return;
Logger.Trace("Sending Exception to Exceptioneer. {0}", Process.GetCurrentProcess().ProcessName);
logEvent.Exception.Data.Add("Message", logEvent.Message);
new Client
{
ApiKey = "43BBF60A-EB2A-4C1C-B09E-422ADF637265",

View File

@ -397,8 +397,10 @@ public virtual void DeleteInvalidEpisodes(Series series, TvdbSeries tvDbSeriesIn
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 episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using NLog;
using Ninject;
using NzbDrone.Core.Model;
@ -23,7 +22,7 @@ public class PostDownloadProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly List<PostDownloadInfoModel> InfoList = new List<PostDownloadInfoModel>();
[Inject]
public PostDownloadProvider(ConfigProvider configProvider, DiskProvider diskProvider,
DiskScanProvider diskScanProvider, SeriesProvider seriesProvider,
@ -38,7 +37,7 @@ public PostDownloadProvider(ConfigProvider configProvider, DiskProvider diskProv
public PostDownloadProvider()
{
}
public virtual void ScanDropFolder(ProgressNotification notification)
@ -85,7 +84,7 @@ public virtual void ProcessDropFolder(string dropFolder)
if (subfolderInfo.Name.StartsWith("_NzbDrone_"))
{
if (subfolderInfo.Name.StartsWith("_NzbDrone_InvalidSeries_"))
ReProcessDownload(new PostDownloadInfoModel{ Name = subfolderInfo.FullName, Status = PostDownloadStatusType.InvalidSeries });
ReProcessDownload(new PostDownloadInfoModel { Name = subfolderInfo.FullName, Status = PostDownloadStatusType.InvalidSeries });
else if (subfolderInfo.Name.StartsWith("_NzbDrone_ParseError_"))
ReProcessDownload(new PostDownloadInfoModel { Name = subfolderInfo.FullName, Status = PostDownloadStatusType.ParseError });
@ -172,18 +171,26 @@ public virtual void ProcessFailedOrUnpackingDownload(DirectoryInfo directoryInfo
return;
}
//Add to InfoList for possible later processing
InfoList.Add(new PostDownloadInfoModel{ Name = directoryInfo.FullName,
Added = DateTime.Now,
Status = postDownloadStatus
});
//Remove the error prefix before processing
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(GetPrefixLength(postDownloadStatus)));
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
var episodeIds = new List<int>();
List<int> episodeIds;
if (parseResult.EpisodeNumbers.Count == 0 && parseResult.FullSeason)
{
episodeIds =
_episodeProvider.GetEpisodesBySeason(parseResult.Series.SeriesId, parseResult.SeasonNumber)
.Select(e => e.EpisodeId).ToList();
.Select(e => e.EpisodeId).ToList();
}
else
episodeIds = _episodeProvider.GetEpisodesByParseResult(parseResult).Select(e => e.EpisodeId).ToList();

35
SharedLiveTemplates.xml Normal file
View File

@ -0,0 +1,35 @@
<TemplatesExport family="Live Templates">
<Template uid="3ec01bf0-ad83-4b4c-a0b2-381f28e3c369" shortcut="Test" description="Test Method" text="[NUnit.Framework.Test]&#xD;&#xA;[NUnit.Framework.Description($TEST_NAME$)]&#xD;&#xA;public void $TEST_METHOD_NAME$() &#xD;&#xA;{&#xD;&#xA; //Act&#xD;&#xA;&#xD;&#xA; //Assert&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;}" reformat="True" shortenQualifiedReferences="True">
<Scopes>
<Scope type="InCSharpTypeMember" minimumLanguageVersion="2.0" />
</Scopes>
<Categories />
<Variables>
<Variable name="TEST_NAME" expression="" initialRange="0" />
<Variable name="TEST_METHOD_NAME" expression="spacestounderstrokes(TEST_METHOD_NAME)" initialRange="-1" />
</Variables>
<CustomProperties />
</Template>
<Template uid="3ec01bf0-ad83-4b4c-a0b2-381f28e3c369" shortcut="Test" description="Test Method" text="[NUnit.Framework.Test]&#xD;&#xA;[NUnit.Framework.Description(&quot;$TEST_NAME$&quot;)]&#xD;&#xA;public void $TEST_METHOD_NAME$() &#xD;&#xA;{&#xD;&#xA; &#xD;&#xA; //Act&#xD;&#xA;&#xD;&#xA; //Assert&#xD;&#xA;&#xD;&#xA;}" reformat="True" shortenQualifiedReferences="True">
<Scopes>
<Scope type="InCSharpTypeMember" minimumLanguageVersion="2.0" />
</Scopes>
<Categories />
<Variables>
<Variable name="TEST_NAME" expression="" initialRange="0" />
<Variable name="TEST_METHOD_NAME" expression="spacestounderstrokes(TEST_NAME)" initialRange="-1" />
</Variables>
<CustomProperties />
</Template>
<Template uid="3ec01bf0-ad83-4b4c-a0b2-381f28e3c369" shortcut="Test" description="Test Method" text="[NUnit.Framework.Test]&#xD;&#xA;[NUnit.Framework.Description(&quot;$TEST_NAME$&quot;)]&#xD;&#xA;public void $TEST_METHOD_NAME$() &#xD;&#xA;{&#xD;&#xA; //Setup&#xD;&#xA;&#xD;&#xA;&#xD;&#xA; //Act&#xD;&#xA;&#xD;&#xA;&#xD;&#xA; //Assert&#xD;&#xA;&#xD;&#xA;}" reformat="True" shortenQualifiedReferences="True">
<Scopes>
<Scope type="InCSharpTypeMember" minimumLanguageVersion="2.0" />
</Scopes>
<Categories />
<Variables>
<Variable name="TEST_NAME" expression="" initialRange="0" />
<Variable name="TEST_METHOD_NAME" expression="spacestounderstrokes(TEST_NAME)" initialRange="-1" />
</Variables>
<CustomProperties />
</Template>
</TemplatesExport>