1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-03-10 15:10:09 -04:00

Compare commits

..

9 Commits

181 changed files with 1044 additions and 2399 deletions

View File

@@ -1,40 +1,5 @@
<!--
Before opening a new issue, please ensure:
- You use the forums for support/questions
- You search for existing bugs/feature requests
- Remove extraneous template details
-->
## Support / Questions
Please use https://forums.sonarr.tv/ for support. Support requests or questions will be redirected to the forums and the issue will be closed.
<!--
Remove if not opening a bug report
-->
## Bug Report
### System Information/Logs
**Sonarr Version:**
**Operating System:**
**.net Framework (Windows) or mono (macOS/Linux) Version:**
**Link to Log Files (debug or trace):**
**Browser (for UI bugs):**
### Additional Information
<!--
Remove if not opening a feature request
-->
## Feature Request
### What problem are you looking to solve?
### Other Information
Provide a description of the feature request or bug, the more details the better.
Please use https://forums.sonarr.tv/ for support or other questions. (When in doubt, use the forums)

7
.github/SUPPORT.md vendored
View File

@@ -1,7 +0,0 @@
## Support
There are a number of frequently asked questions that have been answered in our [FAQ](https://github.com/Sonarr/Sonarr/wiki/FAQ)
The [wiki](https://github.com/Sonarr/Sonarr/wiki) contains other information and guides
If you have a support question, please use the [support forums](https://forums.sonarr.tv/).

View File

@@ -52,7 +52,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -48,8 +48,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<Private>True</Private>
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -1,10 +1,9 @@
using Nancy;
using Nancy;
using System;
using System.Collections.Generic;
using System.Linq;
using Ical.Net;
using Ical.Net.DataTypes;
using Ical.Net.General;
using Ical.Net.Interfaces.Serialization;
using Ical.Net.Serialization;
using Ical.Net.Serialization.iCalendar.Factory;
@@ -93,9 +92,7 @@ namespace NzbDrone.Api.Calendar
ProductId = "-//sonarr.tv//Sonarr//EN"
};
var calendarName = "Sonarr TV Schedule";
calendar.AddProperty(new CalendarProperty("NAME", calendarName));
calendar.AddProperty(new CalendarProperty("X-WR-CALNAME", calendarName));
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value))
{
@@ -117,7 +114,7 @@ namespace NzbDrone.Api.Calendar
if (asAllDay)
{
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value.ToLocalTime()) { HasTime = false };
occurrence.Start = new CalDateTime(episode.AirDateUtc.Value) { HasTime = false };
}
else
{

View File

@@ -23,8 +23,6 @@ namespace NzbDrone.Api.Extensions.Pipelines
private void Handle(NancyContext context)
{
if (context.Request.Method == "OPTIONS") return;
if (_cacheableSpecification.IsCacheable(context))
{
context.Response.Headers.EnableCache();
@@ -35,4 +33,4 @@ namespace NzbDrone.Api.Extensions.Pipelines
}
}
}
}
}

View File

@@ -2,7 +2,6 @@
using System.Linq;
using Nancy;
using Nancy.Bootstrapper;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Api.Extensions.Pipelines
{
@@ -12,25 +11,10 @@ namespace NzbDrone.Api.Extensions.Pipelines
public void Register(IPipelines pipelines)
{
pipelines.BeforeRequest.AddItemToEndOfPipeline(HandleRequest);
pipelines.AfterRequest.AddItemToEndOfPipeline(HandleResponse);
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) Handle);
}
private Response HandleRequest(NancyContext context)
{
if (context == null || context.Request.Method != "OPTIONS")
{
return null;
}
var response = new Response()
.WithStatusCode(HttpStatusCode.OK)
.WithContentType("");
ApplyResponseHeaders(response, context.Request);
return response;
}
private void HandleResponse(NancyContext context)
private void Handle(NancyContext context)
{
if (context == null || context.Response.Headers.ContainsKey(AccessControlHeaders.AllowOrigin))
{
@@ -42,39 +26,21 @@ namespace NzbDrone.Api.Extensions.Pipelines
private static void ApplyResponseHeaders(Response response, Request request)
{
if (request.IsApiRequest())
var allowedMethods = "GET, OPTIONS, PATCH, POST, PUT, DELETE";
if (response.Headers.ContainsKey("Allow"))
{
// Allow Cross-Origin access to the API since it's protected with the apikey, and nothing else.
ApplyCorsResponseHeaders(response, request, "*", "GET, OPTIONS, PATCH, POST, PUT, DELETE");
allowedMethods = response.Headers["Allow"];
}
else if (request.IsSharedContentRequest())
var requestedHeaders = string.Join(", ", request.Headers[AccessControlHeaders.RequestHeaders]);
response.Headers.Add(AccessControlHeaders.AllowOrigin, "*");
response.Headers.Add(AccessControlHeaders.AllowMethods, allowedMethods);
if (request.Headers[AccessControlHeaders.RequestHeaders].Any())
{
// Allow Cross-Origin access to specific shared content such as mediacovers and images.
ApplyCorsResponseHeaders(response, request, "*", "GET, OPTIONS");
}
// Disallow Cross-Origin access for any other route.
}
private static void ApplyCorsResponseHeaders(Response response, Request request, string allowOrigin, string allowedMethods)
{
response.Headers.Add(AccessControlHeaders.AllowOrigin, allowOrigin);
if (request.Method == "OPTIONS")
{
if (response.Headers.ContainsKey("Allow"))
{
allowedMethods = response.Headers["Allow"];
}
response.Headers.Add(AccessControlHeaders.AllowMethods, allowedMethods);
if (request.Headers[AccessControlHeaders.RequestHeaders].Any())
{
var requestedHeaders = request.Headers[AccessControlHeaders.RequestHeaders].Join(", ");
response.Headers.Add(AccessControlHeaders.AllowHeaders, requestedHeaders);
}
response.Headers.Add(AccessControlHeaders.AllowHeaders, requestedHeaders);
}
}
}

View File

@@ -33,8 +33,7 @@ namespace NzbDrone.Api.Extensions.Pipelines
try
{
if (
response.Contents != Response.NoBody
&& !response.ContentType.Contains("image")
!response.ContentType.Contains("image")
&& !response.ContentType.Contains("font")
&& request.Headers.AcceptEncoding.Any(x => x.Contains("gzip"))
&& !AlreadyGzipEncoded(response)
@@ -81,4 +80,4 @@ namespace NzbDrone.Api.Extensions.Pipelines
return false;
}
}
}
}

View File

@@ -36,11 +36,5 @@ namespace NzbDrone.Api.Extensions
{
return request.Path.StartsWith("/Content/", StringComparison.InvariantCultureIgnoreCase);
}
public static bool IsSharedContentRequest(this Request request)
{
return request.Path.StartsWith("/MediaCover/", StringComparison.InvariantCultureIgnoreCase) ||
request.Path.StartsWith("/Content/Images/", StringComparison.InvariantCultureIgnoreCase);
}
}
}

View File

@@ -49,12 +49,7 @@ namespace NzbDrone.Api.Frontend.Mappers
public override bool CanHandle(string resourceUrl)
{
resourceUrl = resourceUrl.ToLowerInvariant();
return !resourceUrl.StartsWith("/content") &&
!resourceUrl.StartsWith("/mediacover") &&
!resourceUrl.Contains(".") &&
!resourceUrl.StartsWith("/login");
return !resourceUrl.Contains(".") && !resourceUrl.StartsWith("/login");
}
public override Response GetResponse(string resourceUrl)
@@ -118,4 +113,4 @@ namespace NzbDrone.Api.Frontend.Mappers
return _generatedContent;
}
}
}
}

View File

@@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using NLog;
@@ -43,7 +42,7 @@ namespace NzbDrone.Api.Frontend.Mappers
public override bool CanHandle(string resourceUrl)
{
return resourceUrl.StartsWith("/MediaCover", StringComparison.InvariantCultureIgnoreCase);
return resourceUrl.StartsWith("/MediaCover");
}
}
}
}

View File

@@ -1,4 +1,3 @@
using System;
using System.IO;
using NLog;
using NzbDrone.Common.Disk;
@@ -29,9 +28,7 @@ namespace NzbDrone.Api.Frontend.Mappers
public override bool CanHandle(string resourceUrl)
{
resourceUrl = resourceUrl.ToLowerInvariant();
return resourceUrl.StartsWith("/content") ||
return resourceUrl.StartsWith("/Content") ||
resourceUrl.EndsWith(".js") ||
resourceUrl.EndsWith(".map") ||
resourceUrl.EndsWith(".css") ||
@@ -40,4 +37,4 @@ namespace NzbDrone.Api.Frontend.Mappers
resourceUrl.EndsWith("oauth.html");
}
}
}
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nancy.Responses;
using NLog;
using Nancy;
using NzbDrone.Api.Frontend.Mappers;

View File

@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System;
using Nancy;
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.REST;
using NzbDrone.Api.Series;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
@@ -28,7 +25,6 @@ namespace NzbDrone.Api.History
_failedDownloadService = failedDownloadService;
GetResourcePaged = GetHistory;
Get["/since"] = x => GetHistorySince();
Post["/failed"] = x => MarkAsFailed();
}
@@ -68,27 +64,6 @@ namespace NzbDrone.Api.History
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
}
private List<HistoryResource> GetHistorySince()
{
var queryDate = Request.Query.Date;
var queryEventType = Request.Query.EventType;
if (!queryDate.HasValue)
{
throw new BadRequestException("date is missing");
}
DateTime date = DateTime.Parse(queryDate.Value);
HistoryEventType? eventType = null;
if (queryEventType.HasValue)
{
eventType = (HistoryEventType)Convert.ToInt32(queryEventType.Value);
}
return _historyService.Since(date, eventType).Select(MapToResource).ToList();
}
private Response MarkAsFailed()
{
var id = (int)Request.Form.Id;

View File

@@ -34,6 +34,7 @@ namespace NzbDrone.Api
RegisterPipelines(pipelines);
container.Resolve<DatabaseTarget>().Register();
container.Resolve<IEventAggregator>().PublishEvent(new ApplicationStartedEvent());
}
private void RegisterPipelines(IPipelines pipelines)
@@ -55,4 +56,4 @@ namespace NzbDrone.Api
protected override byte[] FavIcon => null;
}
}
}

View File

@@ -70,7 +70,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="NodaTime, Version=1.3.0.0, Culture=neutral, PublicKeyToken=4226afe0d9b296d1, processorArchitecture=MSIL">
<HintPath>..\packages\Ical.Net.2.2.32\lib\net40\NodaTime.dll</HintPath>

View File

@@ -6,5 +6,5 @@
<package id="Nancy.Authentication.Basic" version="1.4.1" targetFramework="net40" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
</packages>

View File

@@ -47,12 +47,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -62,6 +58,9 @@
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ContainerFixture.cs" />

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -45,7 +45,7 @@
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="Selenium.Support" version="3.2.0" targetFramework="net40" />
<package id="Selenium.WebDriver" version="3.2.0" targetFramework="net40" />

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using Moq;
@@ -238,7 +238,7 @@ namespace NzbDrone.Common.Test.DiskTests
WithExistingFile(_targetPath);
Assert.Throws<DestinationAlreadyExistsException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
Assert.Throws<IOException>(() => Subject.TransferFile(_sourcePath, _targetPath, TransferMode.Move, false));
Mocker.GetMock<IDiskProvider>()
.Verify(v => v.DeleteFile(_targetPath), Times.Never());

View File

@@ -43,12 +43,8 @@
<Reference Include="FluentAssertions.Core, Version=4.19.0.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\packages\FluentAssertions.4.19.0\lib\net40\FluentAssertions.Core.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -61,6 +57,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="CacheTests\CachedDictionaryFixture.cs" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FluentAssertions" version="4.19.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
</packages>

View File

@@ -1,29 +0,0 @@
using System;
using System.IO;
using System.Runtime.Serialization;
namespace NzbDrone.Common.Disk
{
public class DestinationAlreadyExistsException : IOException
{
public DestinationAlreadyExistsException()
{
}
public DestinationAlreadyExistsException(string message) : base(message)
{
}
public DestinationAlreadyExistsException(string message, int hresult) : base(message, hresult)
{
}
public DestinationAlreadyExistsException(string message, Exception innerException) : base(message, innerException)
{
}
protected DestinationAlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -1,11 +1,10 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Threading;
using NLog;
using NzbDrone.Common.EnsureThat;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Exceptions;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.Disk
@@ -341,7 +340,7 @@ namespace NzbDrone.Common.Disk
}
else
{
throw new DestinationAlreadyExistsException($"Destination {targetPath} already exists.");
throw new IOException(string.Format("Destination already exists. [{0}] to [{1}]", sourcePath, targetPath));
}
}
}

View File

@@ -1,6 +1,4 @@
using NzbDrone.Common.Exceptions;
namespace NzbDrone.Common.Disk
namespace NzbDrone.Common.Exceptions
{
public class NotParentException : NzbDroneException
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
@@ -59,7 +59,7 @@ namespace NzbDrone.Common.Extensions
{
if (!parentPath.IsParentPath(childPath))
{
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
throw new Exceptions.NotParentException("{0} is not a child of {1}", childPath, parentPath);
}
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);

View File

@@ -76,12 +76,5 @@ namespace NzbDrone.Common.Http
var encoding = HttpHeader.GetEncodingFromContentType(Headers.ContentType);
ContentData = encoding.GetBytes(data);
}
public void AddBasicAuthentication(string username, string password)
{
var authInfo = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes($"{username}:{password}"));
Headers.Set("Authorization", "Basic " + authInfo);
}
}
}
}

View File

@@ -44,7 +44,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="Org.Mentalis, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\DotNet4.SocksProxy.1.3.4.0\lib\net40\Org.Mentalis.dll</HintPath>
@@ -92,7 +92,6 @@
<Compile Include="EnvironmentInfo\IOsVersionAdapter.cs" />
<Compile Include="EnvironmentInfo\IPlatformInfo.cs" />
<Compile Include="EnvironmentInfo\OsVersionModel.cs" />
<Compile Include="Disk\DestinationAlreadyExistsException.cs" />
<Compile Include="Exceptions\SonarrStartupException.cs" />
<Compile Include="Extensions\DictionaryExtensions.cs" />
<Compile Include="Disk\OsPath.cs" />
@@ -126,7 +125,7 @@
<Compile Include="EnvironmentInfo\IRuntimeInfo.cs" />
<Compile Include="EnvironmentInfo\RuntimeInfo.cs" />
<Compile Include="EnvironmentInfo\StartupContext.cs" />
<Compile Include="Disk\NotParentException.cs" />
<Compile Include="Exceptions\NotParentException.cs" />
<Compile Include="Exceptions\NzbDroneException.cs" />
<Compile Include="Expansive\CircularReferenceException.cs" />
<Compile Include="Expansive\Expansive.cs" />
@@ -215,11 +214,9 @@
<Compile Include="ServiceFactory.cs" />
<Compile Include="ServiceProvider.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Timeline\TimelineContext.cs" />
<Compile Include="TinyIoC.cs" />
<Compile Include="TPL\Debouncer.cs" />
<Compile Include="TPL\LimitedConcurrencyLevelTaskScheduler.cs" />
<Compile Include="Timeline\ProgressReporter.cs" />
<Compile Include="TPL\RateLimitService.cs" />
<Compile Include="TPL\TaskExtensions.cs" />
<Compile Include="Extensions\TryParseExtensions.cs" />

View File

@@ -1,77 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Common.Timeline
{
public interface IProgressReporter
{
long Raw { get; }
long Total { get; }
double Progress { get; }
void UpdateProgress(long currentProgress, long maxProgress);
void FinishProgress();
}
public class ProgressReporter : IProgressReporter
{
private readonly int _maxSteps;
public long Raw { get; protected set; }
public long Total { get; private set; }
public double Progress => Total == 0 ? 1.0 : Math.Min(Raw, Total) / Total;
//public TimeSpan? EstimatedDurationRemaining { get; private set; }
public ProgressReporter(long initialProgress, long maxProgress, int maxSteps = 100)
{
_maxSteps = maxSteps;
Raw = initialProgress;
Total = maxProgress;
}
public void UpdateProgress(long currentProgress, long maxProgress)
{
bool shouldRaiseEvent;
lock (this)
{
var oldRaw = Raw;
var oldTotal = Total;
Raw = currentProgress;
Total = Total;
var oldStep = oldTotal <= 0 ? _maxSteps : oldRaw * _maxSteps / oldTotal;
var newStep = Total <= 0 ? _maxSteps : Raw * _maxSteps / Total;
shouldRaiseEvent = (oldStep != newStep);
}
if (shouldRaiseEvent)
{
RaiseEvent();
}
}
public void FinishProgress()
{
lock (this)
{
Raw = Total;
}
RaiseEvent();
}
protected virtual void RaiseEvent()
{
// TODO
}
}
}

View File

@@ -1,100 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NzbDrone.Common.Timeline
{
public enum TimelineState
{
Pending,
Started,
Completed,
Failed
}
public interface ITimelineContext : IProgressReporter
{
string Name { get; }
TimelineState State { get; }
void UpdateState(TimelineState state);
ITimelineContext AppendTimeline(string name, long initialProgress = 0, long maxProgress = 1);
void AppendTimeline(ITimelineContext timeline);
}
public class TimelineContext : ProgressReporter, ITimelineContext
{
private List<ITimelineContext> _timelines = new List<ITimelineContext>();
public string Name { get; private set; }
public TimelineState State { get; private set; }
public IEnumerable<ITimelineContext> Timelines
{
get
{
lock (this)
{
return _timelines.ToArray();
}
}
}
public TimelineContext(string name, long initialProgress, long maxProgress)
: base(initialProgress, maxProgress)
{
Name = name;
}
public void UpdateState(TimelineState state)
{
lock (this)
{
State = state;
if (State == TimelineState.Completed || State == TimelineState.Failed)
{
Raw = Total;
}
}
RaiseEvent();
}
public ITimelineContext AppendTimeline(string name, long initialProgress = 0, long maxProgress = 1)
{
lock (this)
{
var timeline = new TimelineContext(name, initialProgress, maxProgress);
_timelines.Add(timeline);
return timeline;
}
}
public void AppendTimeline(ITimelineContext timeline)
{
lock (this)
{
_timelines.Add(timeline);
}
}
protected override void RaiseEvent()
{
lock (this)
{
if (Raw == Total)
{
State = TimelineState.Completed;
}
else
{
State = TimelineState.Started;
}
}
base.RaiseEvent();
}
}
}

View File

@@ -3,6 +3,6 @@
<package id="DotNet4.SocksProxy" version="1.3.4.0" targetFramework="net40" />
<package id="ICSharpCode.SharpZipLib.Patched" version="0.86.5" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="SharpRaven" version="2.2.0" targetFramework="net40" />
</packages>

View File

@@ -57,7 +57,7 @@ namespace NzbDrone.Console
private static void Exit(ExitCodes exitCode)
{
LogManager.Shutdown();
LogManager.Flush();
if (exitCode != ExitCodes.Normal)
{
@@ -80,6 +80,8 @@ namespace NzbDrone.Console
System.Console.ReadLine();
}
//Need this to terminate on mono (thanks nlog)
LogManager.Configuration = null;
Environment.Exit((int)exitCode);
}
}

View File

@@ -79,7 +79,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@@ -3,6 +3,6 @@
<package id="Microsoft.Owin" version="2.1.0" targetFramework="net40" />
<package id="Microsoft.Owin.Hosting" version="2.1.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="Owin" version="1.0" targetFramework="net40" />
</packages>

View File

@@ -1,11 +1,12 @@
using FizzWare.NBuilder;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine.Specifications;
using NzbDrone.Core.DecisionEngine.Specifications.Search;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.TorrentRss;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Test.Common;

View File

@@ -8,7 +8,6 @@ using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients;
using NzbDrone.Core.Download.Pending;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Profiles;
@@ -179,7 +178,7 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
}
[Test]
public void should_return_an_empty_list_when_none_are_approved()
public void should_return_an_empty_list_when_none_are_appproved()
{
var decisions = new List<DownloadDecision>();
decisions.Add(new DownloadDecision(null, new Rejection("Failure!")));
@@ -264,26 +263,5 @@ namespace NzbDrone.Core.Test.Download.DownloadApprovedReportsTests
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteEpisode>(r => r.Release.DownloadProtocol == DownloadProtocol.Usenet)), Times.Once());
Mocker.GetMock<IDownloadService>().Verify(v => v.DownloadReport(It.Is<RemoteEpisode>(r => r.Release.DownloadProtocol == DownloadProtocol.Torrent)), Times.Once());
}
[Test]
public void should_add_to_rejected_if_release_unavailable_on_indexer()
{
var episodes = new List<Episode> { GetEpisode(1) };
var remoteEpisode = GetRemoteEpisode(episodes, new QualityModel(Quality.HDTV720p));
var decisions = new List<DownloadDecision>();
decisions.Add(new DownloadDecision(remoteEpisode));
Mocker.GetMock<IDownloadService>()
.Setup(s => s.DownloadReport(It.IsAny<RemoteEpisode>()))
.Throws(new ReleaseUnavailableException(remoteEpisode.Release, "That 404 Error is not just a Quirk"));
var result = Subject.ProcessDecisions(decisions);
result.Grabbed.Should().BeEmpty();
result.Rejected.Should().NotBeEmpty();
ExceptionVerification.ExpectedWarns(1);
}
}
}

View File

@@ -7,11 +7,12 @@ using NzbDrone.Core.Download.Clients.DownloadStation;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
[TestFixture]
public class SerialNumberProviderFixture : CoreTest<SerialNumberProvider>
public class DSMInfoProviderFixture : CoreTest<DSMInfoProvider>
{
protected DownloadStationSettings _settings;
@@ -24,17 +25,27 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
private void GivenValidResponse()
{
Mocker.GetMock<IDSMInfoProxy>()
.Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns("serial");
.Setup(d => d.GetInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DSMInfoResponse() { SerialNumber = "serial", Version = "DSM 6.0.1" });
}
private void GivenInvalidResponse()
{
Mocker.GetMock<IDSMInfoProxy>()
.Setup(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Setup(d => d.GetInfo(It.IsAny<DownloadStationSettings>()))
.Throws(new DownloadClientException("Serial response invalid"));
}
[Test]
public void should_return_version()
{
GivenValidResponse();
var version = Subject.GetDSMVersion(_settings);
version.Should().Be(new Version("6.0.1"));
}
[Test]
public void should_return_hashedserialnumber()
{
@@ -46,7 +57,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
serial.Should().Be("50DE66B735D30738618568294742FCF1DFA52A47");
Mocker.GetMock<IDSMInfoProxy>()
.Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
.Verify(d => d.GetInfo(It.IsAny<DownloadStationSettings>()), Times.Once());
}
[Test]
@@ -60,7 +71,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
serial2.Should().Be(serial1);
Mocker.GetMock<IDSMInfoProxy>()
.Verify(d => d.GetSerialNumber(It.IsAny<DownloadStationSettings>()), Times.Once());
.Verify(d => d.GetInfo(It.IsAny<DownloadStationSettings>()), Times.Once());
}
[Test]

View File

@@ -12,6 +12,7 @@ using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Test.Common;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
@@ -280,6 +281,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Returns(_downloadStationConfigItems);
}
protected void GivenApiVersions()
{
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Task", MinVersion = 1, MaxVersion = 2 });
Mocker.GetMock<IDownloadStationInfoProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Info", MinVersion = 1, MaxVersion = 3 });
Mocker.GetMock<IFileStationProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "File", MinVersion = 1, MaxVersion = 2 });
}
protected void GivenSharedFolder()
{
Mocker.GetMock<ISharedFolderResolver>()
@@ -289,7 +305,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected void GivenSerialNumber()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns(_serialNumber);
}
@@ -359,6 +375,26 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
return tasks.Count;
}
protected void GivenDSMVersion(string version)
{
Mocker.GetMock<IDSMInfoProvider>()
.Setup(d => d.GetDSMVersion(It.IsAny<DownloadStationSettings>()))
.Returns(new Version(version));
}
[TestCase("6.0.0", 0)]
[TestCase("5.0.0", 1)]
public void TestConnection_should_return_validation_failure_as_expected(string version, int count)
{
GivenApiVersions();
GivenDSMVersion(version);
var result = Subject.Test();
result.Errors.Should().HaveCount(count);
}
[Test]
public void Download_with_TvDirectory_should_force_directory()
{
@@ -460,7 +496,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void GetItems_should_throw_if_serial_number_unavailable()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
@@ -476,7 +512,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
var remoteEpisode = CreateRemoteEpisode();
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

View File

@@ -182,6 +182,21 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
.Returns(_downloadStationConfigItems);
}
protected void GivenApiVersions()
{
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Task", MinVersion = 1, MaxVersion = 2 });
Mocker.GetMock<IDownloadStationInfoProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "Info", MinVersion = 1, MaxVersion = 3 });
Mocker.GetMock<IFileStationProxy>()
.Setup(s => s.GetApiInfo(It.IsAny<DownloadStationSettings>()))
.Returns(new DiskStationApiInfo() { Name = "File", MinVersion = 1, MaxVersion = 2 });
}
protected void GivenSharedFolder()
{
Mocker.GetMock<ISharedFolderResolver>()
@@ -191,7 +206,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
protected void GivenSerialNumber()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(It.IsAny<DownloadStationSettings>()))
.Returns(_serialNumber);
}
@@ -245,6 +260,25 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
Mocker.GetMock<IDownloadStationTaskProxy>()
.Setup(d => d.GetTasks(_settings))
.Returns(tasks);
}
protected void GivenDSMVersion(string version)
{
Mocker.GetMock<IDSMInfoProvider>()
.Setup(d => d.GetDSMVersion(It.IsAny<DownloadStationSettings>()))
.Returns(new Version(version));
}
[TestCase("6.0.0", 0)]
[TestCase("5.0.0", 1)]
public void TestConnection_should_return_validation_failure_as_expected(string version, int count)
{
GivenApiVersions();
GivenDSMVersion(version);
var result = Subject.Test();
result.Errors.Should().HaveCount(count);
}
[Test]
@@ -348,7 +382,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
[Test]
public void GetItems_should_throw_if_serial_number_unavailable()
{
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));
@@ -364,7 +398,7 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.DownloadStationTests
{
var remoteEpisode = CreateRemoteEpisode();
Mocker.GetMock<ISerialNumberProvider>()
Mocker.GetMock<IDSMInfoProvider>()
.Setup(s => s.GetSerialNumber(_settings))
.Throws(new ApplicationException("Some unknown exception, HttpException or DownloadClientException"));

View File

@@ -180,21 +180,6 @@ namespace NzbDrone.Core.Test.Download
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
}
[Test]
public void Download_report_should_not_trigger_indexer_backoff_on_indexer_404_error()
{
var mock = WithUsenetClient();
mock.Setup(s => s.Download(It.IsAny<RemoteEpisode>()))
.Callback<RemoteEpisode>(v => {
throw new ReleaseUnavailableException(v.Release, "Error", new WebException());
});
Assert.Throws<ReleaseUnavailableException>(() => Subject.DownloadReport(_parseResult));
Mocker.GetMock<IIndexerStatusService>()
.Verify(v => v.RecordFailure(It.IsAny<int>(), It.IsAny<TimeSpan>()), Times.Never());
}
[Test]
public void should_not_attempt_download_if_client_isnt_configured()
{
@@ -205,26 +190,18 @@ namespace NzbDrone.Core.Test.Download
}
[Test]
public void should_attempt_download_even_if_client_is_disabled()
public void should_not_attempt_download_if_client_is_disabled()
{
var mockUsenet = WithUsenetClient();
WithUsenetClient();
Mocker.GetMock<IDownloadClientStatusService>()
.Setup(v => v.GetBlockedProviders())
.Returns(new List<DownloadClientStatus>
{
new DownloadClientStatus
{
ProviderId = _downloadClients.First().Definition.Id,
DisabledTill = DateTime.UtcNow.AddHours(3)
}
});
.Setup(v => v.IsDisabled(It.IsAny<int>()))
.Returns(true);
Subject.DownloadReport(_parseResult);
Assert.Throws<DownloadClientUnavailableException>(() => Subject.DownloadReport(_parseResult));
Mocker.GetMock<IDownloadClientStatusService>().Verify(c => c.GetBlockedProviders(), Times.Never());
mockUsenet.Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Once());
VerifyEventPublished<EpisodeGrabbedEvent>();
Mocker.GetMock<IDownloadClient>().Verify(c => c.Download(It.IsAny<RemoteEpisode>()), Times.Never());
VerifyEventNotPublished<EpisodeGrabbedEvent>();
}
[Test]

View File

@@ -1,43 +0,0 @@
using System.IO;
using NUnit.Framework;
using NzbDrone.Core.Download;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Download
{
[TestFixture]
public class NzbValidationServiceFixture : CoreTest<NzbValidationService>
{
private byte[] GivenNzbFile(string name)
{
return File.ReadAllBytes(GetTestPath("Files/Nzbs/" + name + ".nzb"));
}
[Test]
public void should_throw_on_invalid_nzb()
{
var filename = "NotNzb";
var fileContent = GivenNzbFile(filename);
Assert.Throws<InvalidNzbException>(() => Subject.Validate(filename, fileContent));
}
[Test]
public void should_throw_when_no_files()
{
var filename = "NoFiles";
var fileContent = GivenNzbFile(filename);
Assert.Throws<InvalidNzbException>(() => Subject.Validate(filename, fileContent));
}
[Test]
public void should_validate_nzb()
{
var filename = "ValidNzb";
var fileContent = GivenNzbFile(filename);
Subject.Validate(filename, fileContent);
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Marr.Data;
using Moq;
@@ -27,7 +26,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
private ReleaseInfo _release;
private ParsedEpisodeInfo _parsedEpisodeInfo;
private RemoteEpisode _remoteEpisode;
private List<PendingRelease> _heldReleases;
[SetUp]
public void Setup()
@@ -62,27 +60,17 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
_heldReleases = new List<PendingRelease>();
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(_heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
.Returns(new List<PendingRelease>());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});
@@ -92,7 +80,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Returns((List<DownloadDecision> d) => d);
}
private void GivenHeldRelease(string title, string indexer, DateTime publishDate, PendingReleaseReason reason = PendingReleaseReason.Delay)
private void GivenHeldRelease(string title, string indexer, DateTime publishDate)
{
var release = _release.JsonClone();
release.Indexer = indexer;
@@ -104,10 +92,11 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.With(h => h.SeriesId = _series.Id)
.With(h => h.Title = title)
.With(h => h.Release = release)
.With(h => h.Reason = reason)
.Build();
_heldReleases.AddRange(heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(heldReleases);
}
[Test]
@@ -128,29 +117,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
VerifyNoInsert();
}
[Test]
public void should_not_add_if_it_is_the_same_release_from_the_same_indexer_twice()
{
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.DownloadClientUnavailable);
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.Fallback);
Subject.Add(_temporarilyRejected, PendingReleaseReason.Delay);
VerifyNoInsert();
}
[Test]
public void should_remove_duplicate_if_it_is_the_same_release_from_the_same_indexer_twice()
{
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.DownloadClientUnavailable);
GivenHeldRelease(_release.Title, _release.Indexer, _release.PublishDate, PendingReleaseReason.Fallback);
Subject.Add(_temporarilyRejected, PendingReleaseReason.Fallback);
Mocker.GetMock<IPendingReleaseRepository>()
.Verify(v => v.Delete(It.IsAny<int>()), Times.Once());
}
[Test]
public void should_add_if_title_is_different()
{

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using Marr.Data;
using Moq;
@@ -27,7 +26,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
private ReleaseInfo _release;
private ParsedEpisodeInfo _parsedEpisodeInfo;
private RemoteEpisode _remoteEpisode;
private List<PendingRelease> _heldReleases;
[SetUp]
public void Setup()
@@ -62,27 +60,17 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
_heldReleases = new List<PendingRelease>();
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(_heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.AllBySeriesId(It.IsAny<int>()))
.Returns<int>(i => _heldReleases.Where(v => v.SeriesId == i).ToList());
.Returns(new List<PendingRelease>());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});
@@ -104,7 +92,9 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.With(h => h.ParsedEpisodeInfo = parsedEpisodeInfo)
.Build();
_heldReleases.AddRange(heldReleases);
Mocker.GetMock<IPendingReleaseRepository>()
.Setup(s => s.All())
.Returns(heldReleases);
}
[Test]

View File

@@ -38,10 +38,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(new Series());
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { new Series() });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), It.IsAny<Series>(), It.IsAny<bool>(), null))
.Returns(new List<Episode>{ _episode });
@@ -67,7 +63,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
AssertRemoved(1);
}
[Test]
public void should_remove_multiple_releases_release()
{
@@ -138,7 +134,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
AssertRemoved(2);
}
private void AssertRemoved(params int[] ids)
{
Mocker.GetMock<IPendingReleaseRepository>().Verify(c => c.DeleteMany(It.Is<IEnumerable<int>>(s => s.SequenceEqual(ids))));

View File

@@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
_remoteEpisode.Series = _series;
_remoteEpisode.ParsedEpisodeInfo = _parsedEpisodeInfo;
_remoteEpisode.Release = _release;
_temporarilyRejected = new DownloadDecision(_remoteEpisode, new Rejection("Temp Rejected", RejectionType.Temporary));
Mocker.GetMock<IPendingReleaseRepository>()
@@ -73,10 +73,6 @@ namespace NzbDrone.Core.Test.Download.Pending.PendingReleaseServiceTests
.Setup(s => s.GetSeries(It.IsAny<int>()))
.Returns(_series);
Mocker.GetMock<ISeriesService>()
.Setup(s => s.GetSeries(It.IsAny<IEnumerable<int>>()))
.Returns(new List<Series> { _series });
Mocker.GetMock<IParsingService>()
.Setup(s => s.GetEpisodes(It.IsAny<ParsedEpisodeInfo>(), _series, true, null))
.Returns(new List<Episode> {_episode});

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nzb
PUBLIC '-//newzBin//DTD NZB 1.1//EN'
'http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd'>
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
</nzb>

View File

@@ -1,102 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<fail>
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[01/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.nfo&quot; yEnc (1/1)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="12053" number="1">ZQ9h749E781168561i4J0Q6-01m6Q3185@2894t-767038L.Pg7769</segment>
</segments>
</file>
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[02/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.par2&quot; yEnc (1/1)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="26932" number="1">405Z5Y4066010l377VP1k6$U4873W933@f32Bs90575538201.pj54</segment>
</segments>
</file>
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[03/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.r00&quot; yEnc (1/66)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="793068" number="1">1x9894417$M.1s25279485O1s1Fi95Z1_18Z554u440@D1k0854_134551.0794144</segment>
<segment bytes="793234" number="2">48JYp$W18B2R1s2rI24EG7$907$r89875n60@8xK3374080716.115545M</segment>
<segment bytes="793346" number="3">0U93471uI59Y781x77Q8-4286308-4aU35$07-179z@u90567568251.4zgUW968</segment>
<segment bytes="793302" number="4">5119x6417a.s06F$1k46$2q89298-C0@G7C-7811268.bK9x00B</segment>
<segment bytes="793289" number="5">B8$1_h0b64Z14-16_O6$ESw481L421n9agj7731k@414.473581-K$4.0Zd5A</segment>
<segment bytes="793380" number="6">O-4731$tn71v05623J9GT.yc22O975111dR01r58065p@Da1G9L33q74h3095.5X240</segment>
<segment bytes="793253" number="7">d9R03J$07w75945Z556197z50F0w.0-5.x9$58311S@J0-v50033110.4a440EYJ</segment>
<segment bytes="793317" number="8">05e650149.5r1Hk$E0Bko7G5B.1107mz8l17PS8F@vr816$S6T19245w.042B9</segment>
<segment bytes="793060" number="9">245Xy0w4o$tN6428321b.n1816Q1n95bE0816Y@q-qv7E12k.F3672H.16E19</segment>
<segment bytes="793266" number="10">H681i185g64H23101kP125z41101O91P384l@E9n597k05j798D94X.2ezz1K</segment>
<segment bytes="793223" number="11">T18.6136787.HLJ806.8$Si49m0459445101Z15-5@b80M7.788598D.gXu201cR</segment>
<segment bytes="793346" number="12">Vdl8H243Go28j1o865772039416v2@090a20-v365N5S7qf.G225s6</segment>
<segment bytes="793305" number="13">S9769892v956069345.0TN.i05R@I04825Gt2706N.BAj1DT1T</segment>
<segment bytes="793187" number="14">041800q6F28q44365799m5CQ4D43895@1Bf6268z_Q20F.045JXl</segment>
<segment bytes="793119" number="15">1c-e034z4l$9K45i44218ss25$X5_5R-1i76$40-71P@Xt691t8B686Fgv.VBSl</segment>
<segment bytes="793262" number="16">76l441W.R146a5368ed02cp_44171410hT.l@Z98.k.70X9c.5mZ1w49</segment>
<segment bytes="793221" number="17">12D035G5745-KO43wZ9920ttr1338@V7d871S2-t04t8520.uQ18</segment>
<segment bytes="793221" number="18">59V4O77211HA1f5T8h1-53952zV-55294K4M04v@kS878H3g4z.B5561.L330519</segment>
<segment bytes="793087" number="19">44-yi1-79$751944J7094$y7-y49994440d86cSn@5C82v-1O9N.wk8wMb6</segment>
<segment bytes="793375" number="20">oF7Wj3$Ydh7e030oD4.e81JM464O791495lJ@Pm058Qt4-G8Wv.T1i1a6O1</segment>
<segment bytes="793293" number="21">1T7_71M9d10F2.5953VP.11.4h75L@5049bBn384.14Ms</segment>
<segment bytes="793266" number="22">u8601765028G662749SD41j0m57651Zq70u1@J5281423406375.z.6PDSx57</segment>
<segment bytes="793376" number="23">XY0476$R87Y16g2n45OO335541589V140R026j@y2q9296x7f23C.sqK71b9</segment>
<segment bytes="793363" number="24">X7N3440l08B9T5940na4Ls397-T2.P5M12241525J57@r44O419p594M6G4I.d66RQ1</segment>
<segment bytes="793203" number="25">p4148978k45.t88w2K9886H4223y5553T7$7p287TN@N8e1T98b_0.mo55a14G</segment>
<segment bytes="793039" number="26">50U0a9iP07$A66010-51h55w386f@c$42$S96V57F5u0Y.6UDV35D</segment>
<segment bytes="792999" number="27">FnKN4n2749v958xa36J2570506414D293S@8H1A1X490$z3bv.ut6KQ4N</segment>
<segment bytes="793316" number="28">q4$d0$X8x6rm85m0Ewh307m255N@t2C7484zq870u.1RLndQ</segment>
<segment bytes="793238" number="29">364U4342$5I242404oH90-1W3c0t16705057m650Cq9f@K32rE5297347130W.UNs8evbH</segment>
<segment bytes="793461" number="30">M3081U097-r06Y.yy9-1A538001B27f@L2834Y80c7b1075.Dy150</segment>
<segment bytes="793326" number="31">189585554.NS66E5D840N4Yq5m07NC1n@51L0393057L528n.k1Mc3j0S</segment>
<segment bytes="793380" number="32">189048V505q89216C149I5f$53x-T@0V9i8n7o95.I.Z1lBJ5</segment>
<segment bytes="793205" number="33">5-L.555$139r45100-S23-59859@54844694q2.3EY9b</segment>
<segment bytes="793258" number="34">641655313y0.Z002L0g39AZ11716U-uX015PI5.v6y@veS44H89Js91903K8.P3MAvk4k</segment>
<segment bytes="793229" number="35">1C8f-yz-U-b20.610.0P1M-6Z5418i229160865010s1@M7l210D48Nc.nB0sPmi</segment>
<segment bytes="793169" number="36">0653$L0.58749-1U_1PS95-1h9gQ145@0117y0-1x1p-h94.za18yc5</segment>
<segment bytes="793109" number="37">77-Mo3-a6514904987865.K0W710G4HB9237@501F7910J6j50-Bh.6cHx1</segment>
<segment bytes="793350" number="38">m4I47082655rz$b7P751u9W679475F.89p@f.o.XZv5O7y.855rgXX</segment>
<segment bytes="793193" number="39">f075$y56E57d.t11787.0$6D155735M_w89-Y57q2@x0t5H91021wZ52Vh.1h7vabU</segment>
<segment bytes="793251" number="40">H7U1331Ad7718$Y69T-q3w4$l247HV49s985J@vi800i0004p.YD5oK</segment>
<segment bytes="793106" number="41">9nr786955Ker.M583315CoJ1-W65a817-704@IN-wU12$M1E0g466.5sMJ3</segment>
<segment bytes="793006" number="42">0.3R9mN.n2_V086N0-4.Z5gAgZo@ey3G316U382o537.f51Ed5B</segment>
<segment bytes="793198" number="43">l106Z1-N411r7j44197l628r.b5Uwc55@k4-Cl_n5xc.1B.xZbNm</segment>
<segment bytes="793070" number="44">A91LT1X591x81.TI4130N$555A57q0@L70-p5qa50.40GB</segment>
<segment bytes="793457" number="45">V5$765JR6503w0-K63099R615736843G$Qj0ev@mz776wM86445N0.4I56ne</segment>
<segment bytes="793109" number="46">A86H2P415S689$568152-025O45V@s079644915.Dd57p0</segment>
<segment bytes="793169" number="47">31x5o36q14y9554L42882X0Q10e360Z64W4K9Onx38D@5g1509788414q.Y8wib</segment>
<segment bytes="793219" number="48">b$6795157EX1044V964e14-Y9E68614O94C@4061937876$f5.6.19tV</segment>
<segment bytes="793349" number="49">D00v8X$b80m93181273J-g076Qj2p79867v5d9689Rb2@r0592.v900.j43E050E</segment>
<segment bytes="793228" number="50">Tf78L4e535.o86PK0S.M2R3-66012814z@q-5j89Y29J214Y902.53Ra0f</segment>
<segment bytes="793353" number="51">7i01.23411-lQW0212-Er260e9.N5e256jx243EX@91-T.15v40K5Hj.Fo1f</segment>
<segment bytes="793290" number="52">3A$H7m63$i595.4713vv0A4$A7Lk7Jsq@0cM0Tw4107f.B520.q5Z91</segment>
<segment bytes="793364" number="53">j572m$3h87LS$37167Wp10k41541.T779-Fn@V53C11045619xJ.52.0PnnX4v5</segment>
<segment bytes="793506" number="54">A.2d4599a720rk2IB32h0X523MjTL415v89706-7Z45y@R4746-B106358.t3g62r4</segment>
<segment bytes="793118" number="55">5q6100961jM-G9F7t755x366zxc102M1SdMF@7394521p651X1I.AL05545a</segment>
<segment bytes="793137" number="56">04e851111$12u2213-80VR133125B@7x8865M4hQ9$5.1N345x</segment>
<segment bytes="793180" number="57">K2476D3600-73B4W363$008s888980421f27125V$q0@0Zc0a56-m7550.1637vAr1</segment>
<segment bytes="793214" number="58">0306u425024v448ZeCE3Q9825m9th1858@5648018-H0.2k7J4.12k0B</segment>
<segment bytes="793274" number="59">220u4SK433564Cr2l004t0wP888545779g@19j360863S$55559m.70V7Ndr</segment>
<segment bytes="793339" number="60">5u1q051C5Qq8Z9Iy$Z.5.1510NY.S2565n@7m.5-09$z235p74.8kW5</segment>
<segment bytes="793297" number="61">6F472C8nh2621_X0C1093P7n39643b5p2f76s60r@1T55203qQY6.wZml1Vb</segment>
<segment bytes="793351" number="62">5qC4568844767324-o8i05983-0f.n4.y.OBZ41f@q36B50684KU66.0R1784</segment>
<segment bytes="793257" number="63">4P0g470-F59307aDf.JF070Xx959648dO3y00463J6s@71P$D961$C0.11.I096sQ</segment>
<segment bytes="793277" number="64">z5kod75077z01w11-A5h.wiG550.J5-p756$81.Db@5l01K49h3K.Ok4R5512</segment>
<segment bytes="793292" number="65">F3JX28.B8h90T0075-08001X5w611V071@D75X9263$6$9f.OT050p5Z</segment>
<segment bytes="83545" number="66">2B8sT.A650z101514671183y47977219.M4211xYp@0b0021p736BX92.B0lSm4J3</segment>
</segments>
</file>
<file date="1504571157" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[46/46] - &quot;sample-Series.Title.s04e06.720p.hdtv.x264-killers.vol31+04.par2&quot; yEnc (1/3)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="793316" number="1">16ND-8I545Pq-s107t0h07g8908870711@K401476783.5.0mFs1</segment>
<segment bytes="793409" number="2">iYdZ2D11089F310711.ci-O7O4KG03@260c03388O84Kd.GCEgv</segment>
<segment bytes="6784" number="3">r63cDD59Mg1c95738Sn75085O4X7823V1@16V6-b87O21S1937O.lw17o1VS</segment>
</segments>
</file>
</fail>

View File

@@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE nzb
PUBLIC '-//newzBin//DTD NZB 1.1//EN'
'http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd'>
<nzb xmlns="http://www.newzbin.com/DTD/2003/nzb">
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[01/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.nfo&quot; yEnc (1/1)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="12053" number="1">ZQ9h749E781168561i4J0Q6-01m6Q3185@2894t-767038L.Pg7769</segment>
</segments>
</file>
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[02/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.par2&quot; yEnc (1/1)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="26932" number="1">405Z5Y4066010l377VP1k6$U4873W933@f32Bs90575538201.pj54</segment>
</segments>
</file>
<file date="1504571104" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[03/46] - &quot;Series.Title.s04e06.720p.hdtv.x264-killers.r00&quot; yEnc (1/66)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="793068" number="1">1x9894417$M.1s25279485O1s1Fi95Z1_18Z554u440@D1k0854_134551.0794144</segment>
<segment bytes="793234" number="2">48JYp$W18B2R1s2rI24EG7$907$r89875n60@8xK3374080716.115545M</segment>
<segment bytes="793346" number="3">0U93471uI59Y781x77Q8-4286308-4aU35$07-179z@u90567568251.4zgUW968</segment>
<segment bytes="793302" number="4">5119x6417a.s06F$1k46$2q89298-C0@G7C-7811268.bK9x00B</segment>
<segment bytes="793289" number="5">B8$1_h0b64Z14-16_O6$ESw481L421n9agj7731k@414.473581-K$4.0Zd5A</segment>
<segment bytes="793380" number="6">O-4731$tn71v05623J9GT.yc22O975111dR01r58065p@Da1G9L33q74h3095.5X240</segment>
<segment bytes="793253" number="7">d9R03J$07w75945Z556197z50F0w.0-5.x9$58311S@J0-v50033110.4a440EYJ</segment>
<segment bytes="793317" number="8">05e650149.5r1Hk$E0Bko7G5B.1107mz8l17PS8F@vr816$S6T19245w.042B9</segment>
<segment bytes="793060" number="9">245Xy0w4o$tN6428321b.n1816Q1n95bE0816Y@q-qv7E12k.F3672H.16E19</segment>
<segment bytes="793266" number="10">H681i185g64H23101kP125z41101O91P384l@E9n597k05j798D94X.2ezz1K</segment>
<segment bytes="793223" number="11">T18.6136787.HLJ806.8$Si49m0459445101Z15-5@b80M7.788598D.gXu201cR</segment>
<segment bytes="793346" number="12">Vdl8H243Go28j1o865772039416v2@090a20-v365N5S7qf.G225s6</segment>
<segment bytes="793305" number="13">S9769892v956069345.0TN.i05R@I04825Gt2706N.BAj1DT1T</segment>
<segment bytes="793187" number="14">041800q6F28q44365799m5CQ4D43895@1Bf6268z_Q20F.045JXl</segment>
<segment bytes="793119" number="15">1c-e034z4l$9K45i44218ss25$X5_5R-1i76$40-71P@Xt691t8B686Fgv.VBSl</segment>
<segment bytes="793262" number="16">76l441W.R146a5368ed02cp_44171410hT.l@Z98.k.70X9c.5mZ1w49</segment>
<segment bytes="793221" number="17">12D035G5745-KO43wZ9920ttr1338@V7d871S2-t04t8520.uQ18</segment>
<segment bytes="793221" number="18">59V4O77211HA1f5T8h1-53952zV-55294K4M04v@kS878H3g4z.B5561.L330519</segment>
<segment bytes="793087" number="19">44-yi1-79$751944J7094$y7-y49994440d86cSn@5C82v-1O9N.wk8wMb6</segment>
<segment bytes="793375" number="20">oF7Wj3$Ydh7e030oD4.e81JM464O791495lJ@Pm058Qt4-G8Wv.T1i1a6O1</segment>
<segment bytes="793293" number="21">1T7_71M9d10F2.5953VP.11.4h75L@5049bBn384.14Ms</segment>
<segment bytes="793266" number="22">u8601765028G662749SD41j0m57651Zq70u1@J5281423406375.z.6PDSx57</segment>
<segment bytes="793376" number="23">XY0476$R87Y16g2n45OO335541589V140R026j@y2q9296x7f23C.sqK71b9</segment>
<segment bytes="793363" number="24">X7N3440l08B9T5940na4Ls397-T2.P5M12241525J57@r44O419p594M6G4I.d66RQ1</segment>
<segment bytes="793203" number="25">p4148978k45.t88w2K9886H4223y5553T7$7p287TN@N8e1T98b_0.mo55a14G</segment>
<segment bytes="793039" number="26">50U0a9iP07$A66010-51h55w386f@c$42$S96V57F5u0Y.6UDV35D</segment>
<segment bytes="792999" number="27">FnKN4n2749v958xa36J2570506414D293S@8H1A1X490$z3bv.ut6KQ4N</segment>
<segment bytes="793316" number="28">q4$d0$X8x6rm85m0Ewh307m255N@t2C7484zq870u.1RLndQ</segment>
<segment bytes="793238" number="29">364U4342$5I242404oH90-1W3c0t16705057m650Cq9f@K32rE5297347130W.UNs8evbH</segment>
<segment bytes="793461" number="30">M3081U097-r06Y.yy9-1A538001B27f@L2834Y80c7b1075.Dy150</segment>
<segment bytes="793326" number="31">189585554.NS66E5D840N4Yq5m07NC1n@51L0393057L528n.k1Mc3j0S</segment>
<segment bytes="793380" number="32">189048V505q89216C149I5f$53x-T@0V9i8n7o95.I.Z1lBJ5</segment>
<segment bytes="793205" number="33">5-L.555$139r45100-S23-59859@54844694q2.3EY9b</segment>
<segment bytes="793258" number="34">641655313y0.Z002L0g39AZ11716U-uX015PI5.v6y@veS44H89Js91903K8.P3MAvk4k</segment>
<segment bytes="793229" number="35">1C8f-yz-U-b20.610.0P1M-6Z5418i229160865010s1@M7l210D48Nc.nB0sPmi</segment>
<segment bytes="793169" number="36">0653$L0.58749-1U_1PS95-1h9gQ145@0117y0-1x1p-h94.za18yc5</segment>
<segment bytes="793109" number="37">77-Mo3-a6514904987865.K0W710G4HB9237@501F7910J6j50-Bh.6cHx1</segment>
<segment bytes="793350" number="38">m4I47082655rz$b7P751u9W679475F.89p@f.o.XZv5O7y.855rgXX</segment>
<segment bytes="793193" number="39">f075$y56E57d.t11787.0$6D155735M_w89-Y57q2@x0t5H91021wZ52Vh.1h7vabU</segment>
<segment bytes="793251" number="40">H7U1331Ad7718$Y69T-q3w4$l247HV49s985J@vi800i0004p.YD5oK</segment>
<segment bytes="793106" number="41">9nr786955Ker.M583315CoJ1-W65a817-704@IN-wU12$M1E0g466.5sMJ3</segment>
<segment bytes="793006" number="42">0.3R9mN.n2_V086N0-4.Z5gAgZo@ey3G316U382o537.f51Ed5B</segment>
<segment bytes="793198" number="43">l106Z1-N411r7j44197l628r.b5Uwc55@k4-Cl_n5xc.1B.xZbNm</segment>
<segment bytes="793070" number="44">A91LT1X591x81.TI4130N$555A57q0@L70-p5qa50.40GB</segment>
<segment bytes="793457" number="45">V5$765JR6503w0-K63099R615736843G$Qj0ev@mz776wM86445N0.4I56ne</segment>
<segment bytes="793109" number="46">A86H2P415S689$568152-025O45V@s079644915.Dd57p0</segment>
<segment bytes="793169" number="47">31x5o36q14y9554L42882X0Q10e360Z64W4K9Onx38D@5g1509788414q.Y8wib</segment>
<segment bytes="793219" number="48">b$6795157EX1044V964e14-Y9E68614O94C@4061937876$f5.6.19tV</segment>
<segment bytes="793349" number="49">D00v8X$b80m93181273J-g076Qj2p79867v5d9689Rb2@r0592.v900.j43E050E</segment>
<segment bytes="793228" number="50">Tf78L4e535.o86PK0S.M2R3-66012814z@q-5j89Y29J214Y902.53Ra0f</segment>
<segment bytes="793353" number="51">7i01.23411-lQW0212-Er260e9.N5e256jx243EX@91-T.15v40K5Hj.Fo1f</segment>
<segment bytes="793290" number="52">3A$H7m63$i595.4713vv0A4$A7Lk7Jsq@0cM0Tw4107f.B520.q5Z91</segment>
<segment bytes="793364" number="53">j572m$3h87LS$37167Wp10k41541.T779-Fn@V53C11045619xJ.52.0PnnX4v5</segment>
<segment bytes="793506" number="54">A.2d4599a720rk2IB32h0X523MjTL415v89706-7Z45y@R4746-B106358.t3g62r4</segment>
<segment bytes="793118" number="55">5q6100961jM-G9F7t755x366zxc102M1SdMF@7394521p651X1I.AL05545a</segment>
<segment bytes="793137" number="56">04e851111$12u2213-80VR133125B@7x8865M4hQ9$5.1N345x</segment>
<segment bytes="793180" number="57">K2476D3600-73B4W363$008s888980421f27125V$q0@0Zc0a56-m7550.1637vAr1</segment>
<segment bytes="793214" number="58">0306u425024v448ZeCE3Q9825m9th1858@5648018-H0.2k7J4.12k0B</segment>
<segment bytes="793274" number="59">220u4SK433564Cr2l004t0wP888545779g@19j360863S$55559m.70V7Ndr</segment>
<segment bytes="793339" number="60">5u1q051C5Qq8Z9Iy$Z.5.1510NY.S2565n@7m.5-09$z235p74.8kW5</segment>
<segment bytes="793297" number="61">6F472C8nh2621_X0C1093P7n39643b5p2f76s60r@1T55203qQY6.wZml1Vb</segment>
<segment bytes="793351" number="62">5qC4568844767324-o8i05983-0f.n4.y.OBZ41f@q36B50684KU66.0R1784</segment>
<segment bytes="793257" number="63">4P0g470-F59307aDf.JF070Xx959648dO3y00463J6s@71P$D961$C0.11.I096sQ</segment>
<segment bytes="793277" number="64">z5kod75077z01w11-A5h.wiG550.J5-p756$81.Db@5l01K49h3K.Ok4R5512</segment>
<segment bytes="793292" number="65">F3JX28.B8h90T0075-08001X5w611V071@D75X9263$6$9f.OT050p5Z</segment>
<segment bytes="83545" number="66">2B8sT.A650z101514671183y47977219.M4211xYp@0b0021p736BX92.B0lSm4J3</segment>
</segments>
</file>
<file date="1504571157" poster="autom@gical.tv (M@GiC)" subject="[432278]-[FULL]-[#a.b.teevee@EFNet]-[ Series.Title.S04E06.720p.HDTV.x264-KILLERS ]-[46/46] - &quot;sample-Series.Title.s04e06.720p.hdtv.x264-killers.vol31+04.par2&quot; yEnc (1/3)">
<groups>
<group>alt.binaries.teevee</group>
</groups>
<segments>
<segment bytes="793316" number="1">16ND-8I545Pq-s107t0h07g8908870711@K401476783.5.0mFs1</segment>
<segment bytes="793409" number="2">iYdZ2D11089F310711.ci-O7O4KG03@260c03388O84Kd.GCEgv</segment>
<segment bytes="6784" number="3">r63cDD59Mg1c95738Sn75085O4X7823V1@16V6-b87O21S1937O.lw17o1VS</segment>
</segments>
</file>
</nzb>

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
Mocker.GetMock<IIndexerStatusRepository>()
.Verify(v => v.UpdateMany(
It.Is<List<IndexerStatus>>(i => i.All(
s => s.InitialFailure.Value <= DateTime.UtcNow))
s => s.InitialFailure.Value < DateTime.UtcNow))
)
);
}
@@ -85,7 +85,7 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
Mocker.GetMock<IIndexerStatusRepository>()
.Verify(v => v.UpdateMany(
It.Is<List<IndexerStatus>>(i => i.All(
s => s.MostRecentFailure.Value <= DateTime.UtcNow))
s => s.MostRecentFailure.Value < DateTime.UtcNow))
)
);
}
@@ -116,4 +116,4 @@ namespace NzbDrone.Core.Test.Housekeeping.Housekeepers
}
}
}

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
_quality = new QualityModel(Quality.DVD);
_localEpisode = new LocalEpisode
{
{
Series = _series,
Quality = _quality,
Episodes = new List<Episode> { new Episode() },
@@ -231,7 +231,7 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport
Mocker.GetMock<IParsingService>()
.Setup(c => c.GetLocalEpisode(It.IsAny<string>(), It.IsAny<Series>(), It.IsAny<ParsedEpisodeInfo>(), It.IsAny<bool>()))
.Returns(new LocalEpisode() { Path = "test", ParsedEpisodeInfo = new ParsedEpisodeInfo { } });
.Returns(new LocalEpisode() { Path = "test" });
_videoFiles = new List<string>
{

View File

@@ -145,33 +145,5 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2.0m);
}
[Test]
public void should_use_AudioChannelPositionText_when_AudioChannelChannelPosition_is_invalid()
{
var mediaInfoModel = new MediaInfoModel
{
AudioChannels = 6,
AudioChannelPositions = "15 objects",
AudioChannelPositionsText = "15 objects / Front: L C R, Side: L R, LFE",
SchemaRevision = 3
};
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
}
[Test]
public void should_remove_atmos_objects_from_AudioChannelPostions()
{
var mediaInfoModel = new MediaInfoModel
{
AudioChannels = 2,
AudioChannelPositions = "15 objects / 3/2.1",
AudioChannelPositionsText = null,
SchemaRevision = 3
};
MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m);
}
}
}

View File

@@ -60,7 +60,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.CURRENT_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()
@@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
.All()
.With(v => v.RelativePath = "media.mkv")
.TheFirst(1)
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = VideoFileInfoReader.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.With(v => v.MediaInfo = new MediaInfoModel { SchemaRevision = UpdateMediaInfoService.MINIMUM_MEDIA_INFO_SCHEMA_REVISION })
.BuildList();
Mocker.GetMock<IMediaFileService>()

View File

@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@@ -46,7 +46,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
info.VideoProfile.Should().Be("Baseline@L2.1");
info.VideoCodecLibrary.Should().Be("");
info.AudioFormat.Should().Be("AAC");
info.AudioCodecID.Should().BeOneOf("40", "mp4a-40-2");
info.AudioCodecID.Should().Be("40");
info.AudioProfile.Should().Be("LC");
info.AudioCodecLibrary.Should().Be("");
info.AudioBitrate.Should().Be(128000);
@@ -82,7 +82,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
info.VideoProfile.Should().Be("Baseline@L2.1");
info.VideoCodecLibrary.Should().Be("");
info.AudioFormat.Should().Be("AAC");
info.AudioCodecID.Should().BeOneOf("40", "mp4a-40-2");
info.AudioCodecID.Should().Be("40");
info.AudioProfile.Should().Be("LC");
info.AudioCodecLibrary.Should().Be("");
info.AudioBitrate.Should().Be(128000);

View File

@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
@@ -7,7 +7,6 @@ using Moq;
using NUnit.Framework;
using NzbDrone.Common.Disk;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.EpisodeImport;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Tv;
@@ -34,16 +33,12 @@ namespace NzbDrone.Core.Test.MediaFiles
.Build();
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(Directory.GetParent(_localEpisode.Series.Path).FullName))
.Returns(true);
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
.Returns<string>(c => Path.GetDirectoryName(c));
.Setup(c => c.GetParentFolder(It.IsAny<string>()))
.Returns<string>(c => Path.GetDirectoryName(c));
}
private void GivenSingleEpisodeWithSingleEpisodeFile()
@@ -180,19 +175,5 @@ namespace NzbDrone.Core.Test.MediaFiles
Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode).OldFiles.Count.Should().Be(2);
}
[Test]
public void should_throw_if_there_are_existing_episode_files_and_the_root_folder_is_missing()
{
GivenSingleEpisodeWithSingleEpisodeFile();
Mocker.GetMock<IDiskProvider>()
.Setup(c => c.FolderExists(Directory.GetParent(_localEpisode.Series.Path).FullName))
.Returns(false);
Assert.Throws<RootFolderNotFoundException>(() => Subject.UpgradeEpisodeFile(_episodeFile, _localEpisode));
Mocker.GetMock<IMediaFileService>().Verify(v => v.Delete(_localEpisode.Episodes.Single().EpisodeFile.Value, DeleteMediaFileReason.Upgrade), Times.Never());
}
}
}

View File

@@ -35,15 +35,6 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Returns(_executorB.Object);
}
[TearDown]
public void TearDown()
{
Subject.Handle(new ApplicationShutdownRequested());
// Give the threads a bit of time to shut down.
Thread.Sleep(10);
}
private void GivenCommandQueue()
{
_commandQueue = new BlockingCollection<CommandModel>(new CommandQueue());
@@ -53,10 +44,8 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Returns(_commandQueue.GetConsumingEnumerable);
}
private void QueueAndWaitForExecution(CommandModel commandModel)
private void WaitForExecution(CommandModel commandModel)
{
Thread.Sleep(10);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), It.IsAny<string>()))
.Callback(() => _commandExecuted = true);
@@ -65,14 +54,12 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Setup(s => s.Fail(It.Is<CommandModel>(c => c == commandModel), It.IsAny<string>(), It.IsAny<Exception>()))
.Callback(() => _commandExecuted = true);
_commandQueue.Add(commandModel);
while (!_commandExecuted)
{
Thread.Sleep(100);
}
Thread.Sleep(10);
var t1 = 1;
}
[Test]
@@ -95,8 +82,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
}
@@ -112,8 +100,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
_executorA.Verify(c => c.Execute(commandA), Times.Once());
_executorB.Verify(c => c.Execute(It.IsAny<CommandB>()), Times.Never());
@@ -133,8 +122,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
.Throws(new NotImplementedException());
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
VerifyEventPublished<CommandExecutedEvent>();
ExceptionVerification.ExpectedErrors(1);
@@ -151,8 +141,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
VerifyEventPublished<CommandExecutedEvent>();
}
@@ -168,8 +159,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandA.CompletionMessage))
@@ -188,8 +180,9 @@ namespace NzbDrone.Core.Test.Messaging.Commands
};
Subject.Handle(new ApplicationStartedEvent());
_commandQueue.Add(commandModel);
QueueAndWaitForExecution(commandModel);
WaitForExecution(commandModel);
Mocker.GetMock<IManageCommandQueue>()
.Setup(s => s.Complete(It.Is<CommandModel>(c => c == commandModel), commandModel.Message))
@@ -209,10 +202,10 @@ namespace NzbDrone.Core.Test.Messaging.Commands
public CommandB()
{
}
public override string CompletionMessage => null;
}
}
}

View File

@@ -77,10 +77,6 @@
<HintPath>..\packages\Unity.2.1.505.2\lib\NET35\Microsoft.Practices.Unity.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NCrunch.Framework, Version=3.2.0.3, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea, processorArchitecture=MSIL">
<HintPath>..\packages\NCrunch.Framework.3.2.0.3\lib\NCrunch.Framework.dll</HintPath>
<Private>True</Private>
@@ -90,7 +86,7 @@
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.4.12\lib\net40\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.4.3\lib\net40\NLog.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.6.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll</HintPath>
@@ -101,6 +97,9 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920">
<HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath>
</Reference>
<Reference Include="Prowlin">
<HintPath>..\packages\Prowlin.0.9.4456.26422\lib\net40\Prowlin.dll</HintPath>
</Reference>
@@ -177,7 +176,7 @@
<Compile Include="Download\DownloadClientTests\DelugeTests\DelugeFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadClientFixtureBase.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\TorrentDownloadStationFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SerialNumberProviderFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\DSMInfoProviderFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\SharedFolderResolverFixture.cs" />
<Compile Include="Download\DownloadClientTests\DownloadStationTests\UsenetDownloadStationFixture.cs" />
<Compile Include="Download\DownloadClientTests\HadoukenTests\HadoukenFixture.cs" />
@@ -195,7 +194,6 @@
<Compile Include="Download\DownloadClientTests\VuzeTests\VuzeFixture.cs" />
<Compile Include="Download\DownloadServiceFixture.cs" />
<Compile Include="Download\FailedDownloadServiceFixture.cs" />
<Compile Include="Download\NzbValidationServiceFixture.cs" />
<Compile Include="Download\Pending\PendingReleaseServiceTests\PendingReleaseServiceFixture.cs" />
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemovePendingFixture.cs" />
<Compile Include="Download\Pending\PendingReleaseServiceTests\RemoveRejectedFixture.cs" />
@@ -572,12 +570,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<None Include="Files\Nzbs\NotNzb.nzb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Files\Nzbs\NoFiles.nzb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Files\TestArchive.tar.gz">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -596,9 +588,6 @@
<Content Include="Files\Xem\Names.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Files\Nzbs\ValidNzb.nzb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@@ -34,7 +34,6 @@ namespace NzbDrone.Core.Test.ParserTests
public void should_parse_from_path(string path, int season, int episode)
{
var result = Parser.Parser.ParsePath(path.AsOsAgnostic());
result.EpisodeNumbers.Should().HaveCount(1);
result.SeasonNumber.Should().Be(season);
result.EpisodeNumbers[0].Should().Be(episode);
@@ -43,20 +42,5 @@ namespace NzbDrone.Core.Test.ParserTests
ExceptionVerification.IgnoreWarns();
}
[TestCase("01-03\\The Series Title (2010) - 1x01-02-03 - Episode Title HDTV-720p Proper", "The Series Title (2010)", 1, new [] { 1, 2, 3 })]
public void should_parse_multi_episode_from_path(string path, string title, int season, int[] episodes)
{
var result = Parser.Parser.ParsePath(path.AsOsAgnostic());
result.SeriesTitle.Should().Be(title);
result.EpisodeNumbers.Should().HaveCount(episodes.Length);
result.SeasonNumber.Should().Be(season);
result.EpisodeNumbers.Should().BeEquivalentTo(episodes);
result.AbsoluteEpisodeNumbers.Should().BeEmpty();
result.FullSeason.Should().BeFalse();
ExceptionVerification.IgnoreWarns();
}
}
}

View File

@@ -1,4 +1,4 @@
using FluentAssertions;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Qualities;
@@ -117,7 +117,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("[Eveyuu] No Game No Life - 10 [Hi10P 1280x720 H264][10B23BD8]", false)]
[TestCase("Hells.Kitchen.US.S12E17.HR.WS.PDTV.X264-DIMENSION", false)]
[TestCase("Survivorman.The.Lost.Pilots.Summer.HR.WS.PDTV.x264-DHD", false)]
[TestCase("Victoria S01E07 - Motor zmen (CZ)[TvRip][HEVC][720p]", false)]
public void should_parse_hdtv720p_quality(string title, bool proper)
{
ParseAndVerifyQuality(title, Quality.HDTV720p, proper);
@@ -129,7 +128,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("DEXTER.S07E01.ARE.YOU.1080P.HDTV.proper.X264-QCF", true)]
[TestCase("Dexter - S01E01 - Title [HDTV-1080p]", false)]
[TestCase("[HorribleSubs] Yowamushi Pedal - 32 [1080p]", false)]
[TestCase("Victoria S01E07 - Motor zmen (CZ)[TvRip][HEVC][1080p]", false)]
public void should_parse_hdtv1080p_quality(string title, bool proper)
{
ParseAndVerifyQuality(title, Quality.HDTV1080p, proper);

View File

@@ -129,7 +129,6 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("Jeopardy - 2016x231", "Jeopardy", 2016, 231)]
[TestCase("Shortland.Street.S26E022.HDTV.x264-FiHTV", "Shortland Street", 26, 22)]
[TestCase("Super.Potatoes.S01.Ep06.1080p.BluRay.DTS.x264-MiR", "Super Potatoes", 1, 6)]
[TestCase("Room 104 - S01E07 The Missionaries [SDTV]", "Room 104", 1, 7)]
//[TestCase("", "", 0, 0)]
public void should_parse_single_episode(string postTitle, string title, int seasonNumber, int episodeNumber)
{

View File

@@ -6,10 +6,10 @@
<package id="FluentMigrator" version="1.6.2" targetFramework="net40" />
<package id="FluentMigrator.Runner" version="1.6.2" targetFramework="net40" />
<package id="FluentValidation" version="6.2.1.0" targetFramework="net40" />
<package id="Moq" version="4.0.10827" targetFramework="net40" />
<package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="4.0.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net40" />
<package id="NLog" version="4.4.12" targetFramework="net40" />
<package id="NLog" version="4.4.3" targetFramework="net40" />
<package id="NUnit" version="3.6.0" targetFramework="net40" />
<package id="Prowlin" version="0.9.4456.26422" targetFramework="net40" />
<package id="Unity" version="2.1.505.2" targetFramework="net40" />

View File

@@ -1,14 +0,0 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(118)]
public class add_history_eventType_index : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Create.Index().OnTable("History").OnColumn("EventType");
}
}
}

View File

@@ -15,6 +15,7 @@ using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Jobs;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Profiles.Delay;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Notifications;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
@@ -104,7 +105,8 @@ namespace NzbDrone.Core.Datastore
Mapper.Entity<PendingRelease>().RegisterModel("PendingReleases")
.Ignore(e => e.RemoteEpisode);
Mapper.Entity<RemotePathMapping>().RegisterModel("RemotePathMappings");
Mapper.Entity<Tag>().RegisterModel("Tags");
Mapper.Entity<Restriction>().RegisterModel("Restrictions");

View File

@@ -81,7 +81,7 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
var episodeIds = subject.Episodes.Select(e => e.Id);
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds.ToArray());
var oldest = _pendingReleaseService.OldestPendingRelease(subject.Series.Id, episodeIds);
if (oldest != null && oldest.Release.AgeMinutes > delay)
{

View File

@@ -4,7 +4,7 @@ using NzbDrone.Core.Indexers;
using NzbDrone.Core.IndexerSearch.Definitions;
using NzbDrone.Core.Parser.Model;
namespace NzbDrone.Core.DecisionEngine.Specifications
namespace NzbDrone.Core.DecisionEngine.Specifications.Search
{
public class TorrentSeedingSpecification : IDecisionEngineSpecification
{

View File

@@ -11,6 +11,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Download.Clients.Blackhole
@@ -28,8 +29,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_scanWatchFolder = scanWatchFolder;
@@ -97,7 +99,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
TotalSize = item.TotalSize,
RemainingTime = item.RemainingTime,
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
OutputPath = item.OutputPath,
Status = item.Status,
@@ -122,7 +124,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
return new DownloadClientInfo
{
IsLocalhost = true,
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
};
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using FluentValidation.Results;
@@ -9,6 +9,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Blackhole
{
@@ -22,9 +23,9 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IValidateNzbs nzbValidationService,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_scanWatchFolder = scanWatchFolder;
@@ -65,7 +66,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
TotalSize = item.TotalSize,
RemainingTime = item.RemainingTime,
OutputPath = new DownloadClientPath(Definition.Id, item.OutputPath),
OutputPath = item.OutputPath,
Status = item.Status,
@@ -90,7 +91,7 @@ namespace NzbDrone.Core.Download.Clients.Blackhole
return new DownloadClientInfo
{
IsLocalhost = true,
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(Settings.WatchFolder)) }
OutputRootFolders = new List<OsPath> { new OsPath(Settings.WatchFolder) }
};
}

View File

@@ -11,6 +11,7 @@ using NzbDrone.Core.Validation;
using NLog;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Deluge
{
@@ -23,8 +24,9 @@ namespace NzbDrone.Core.Download.Clients.Deluge
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -104,8 +106,8 @@ namespace NzbDrone.Core.Download.Clients.Deluge
item.DownloadClient = Definition.Name;
var outputPath = new OsPath(torrent.DownloadPath) + torrent.Name;
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.DownloadPath));
item.OutputPath = outputPath + torrent.Name;
item.RemainingSize = torrent.Size - torrent.BytesDownloaded;
try
@@ -174,7 +176,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
}
return status;

View File

@@ -0,0 +1,62 @@
using System;
using System.Text.RegularExpressions;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Crypto;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{
public interface IDSMInfoProvider
{
string GetSerialNumber(DownloadStationSettings settings);
Version GetDSMVersion(DownloadStationSettings settings);
}
public class DSMInfoProvider : IDSMInfoProvider
{
private readonly IDSMInfoProxy _proxy;
private ICached<DSMInfoResponse> _cache;
private readonly ILogger _logger;
public DSMInfoProvider(ICacheManager cacheManager,
IDSMInfoProxy proxy,
Logger logger)
{
_proxy = proxy;
_cache = cacheManager.GetCache<DSMInfoResponse>(GetType());
_logger = logger;
}
private DSMInfoResponse GetInfo(DownloadStationSettings settings)
{
return _cache.Get(settings.Host, () => _proxy.GetInfo(settings), TimeSpan.FromMinutes(5));
}
public string GetSerialNumber(DownloadStationSettings settings)
{
try
{
return HashConverter.GetHash(GetInfo(settings).SerialNumber).ToHexString();
}
catch (Exception ex)
{
_logger.Warn(ex, "Could not get the serial number from Download Station {0}:{1}", settings.Host, settings.Port);
throw;
}
}
public Version GetDSMVersion(DownloadStationSettings settings)
{
var info = GetInfo(settings);
Regex regex = new Regex(@"DSM (?<version>[\d.]*)");
var dsmVersion = regex.Match(info.Version).Groups["version"].Value;
return new Version(dsmVersion);
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

View File

@@ -1,5 +1,5 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{

View File

@@ -1,10 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static NzbDrone.Core.Download.Clients.DownloadStation.DownloadStationTask;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{

View File

@@ -1,15 +1,13 @@
using System;
using System.Collections.Generic;
using NLog;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
using NzbDrone.Core.Download.Clients.DownloadStation.Responses;
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
public interface IDSMInfoProxy
public interface IDSMInfoProxy : IDiskStationProxy
{
string GetSerialNumber(DownloadStationSettings settings);
DSMInfoResponse GetInfo(DownloadStationSettings settings);
}
public class DSMInfoProxy : DiskStationProxyBase, IDSMInfoProxy
@@ -19,15 +17,15 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
}
public string GetSerialNumber(DownloadStationSettings settings)
public DSMInfoResponse GetInfo(DownloadStationSettings settings)
{
var info = GetApiInfo(settings);
var requestBuilder = BuildRequest(settings, "getinfo", info.MinVersion);
var response = ProcessRequest<DSMInfoResponse>(requestBuilder, "get serial number", settings);
var response = ProcessRequest<DSMInfoResponse>(requestBuilder, "get info", settings);
return response.Data.SerialNumber;
return response.Data;
}
}
}

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using NLog;
using NzbDrone.Common.Cache;
@@ -161,7 +160,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
if (apiInfo.NeedsAuthentication)
{
requestBuilder.AddFormParameter("_sid", _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6)));
var sid = _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6));
_logger.Debug("DownloadStation Session sid={0}", sid);
requestBuilder.AddFormParameter("_sid", sid);
}
requestBuilder.AddFormParameter("api", apiInfo.Name);
@@ -172,7 +173,9 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
if (apiInfo.NeedsAuthentication)
{
requestBuilder.AddQueryParam("_sid", _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6)));
var sid = _sessionCache.Get(GenerateSessionCacheKey(settings), () => AuthenticateClient(settings), TimeSpan.FromHours(6));
_logger.Debug("DownloadStation Session sid={0}", sid);
requestBuilder.AddQueryParam("_sid", sid);
}
requestBuilder.AddQueryParam("api", apiInfo.Name);

View File

@@ -1,7 +1,7 @@
using NLog;
using NzbDrone.Common.Http;
using System.Collections.Generic;
using System.Collections.Generic;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Http;
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{

View File

@@ -0,0 +1,8 @@
namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
{
public class ExpectedVersion
{
public int Version { get; set; }
public IDiskStationProxy Proxy { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Cache;
@@ -18,11 +17,17 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
public class FileStationProxy : DiskStationProxyBase, IFileStationProxy
{
public FileStationProxy(IHttpClient httpClient, ICacheManager cacheManager, Logger logger)
private IDSMInfoProvider _dsmInfoProvider;
public FileStationProxy(IDSMInfoProvider dsmInfoProvider,
IHttpClient httpClient,
ICacheManager cacheManager,
Logger logger)
: base(DiskStationApi.FileStationList, "SYNO.FileStation.List", httpClient, cacheManager, logger)
{
_dsmInfoProvider = dsmInfoProvider;
}
public SharedFolderMapping GetSharedFolderMapping(string sharedFolder, DownloadStationSettings settings)
{
var info = GetInfoFileOrDirectory(sharedFolder, settings);
@@ -34,13 +39,16 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies
public FileStationListFileInfoResponse GetInfoFileOrDirectory(string path, DownloadStationSettings settings)
{
var requestBuilder = BuildRequest(settings, "getinfo", 2);
var dsmVersion = _dsmInfoProvider.GetDSMVersion(settings);
var requestBuilder = BuildRequest(settings, "getinfo", dsmVersion >= new Version(6, 0, 0) ? 2 : 1);
requestBuilder.AddQueryParam("path", new[] { path }.ToJson());
requestBuilder.AddQueryParam("additional", "[\"real_path\"]");
var response = ProcessRequest<FileStationListResponse>(requestBuilder, $"get info of {path}", settings);
return response.Data.Files.First();
}
}
}

View File

@@ -6,5 +6,8 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Responses
{
[JsonProperty("serial")]
public string SerialNumber { get; set; }
[JsonProperty("version_string")]
public string Version { get; set; }
}
}

View File

@@ -1,49 +0,0 @@
using System;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Common.Crypto;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
namespace NzbDrone.Core.Download.Clients.DownloadStation
{
public interface ISerialNumberProvider
{
string GetSerialNumber(DownloadStationSettings settings);
}
public class SerialNumberProvider : ISerialNumberProvider
{
private readonly IDSMInfoProxy _proxy;
private ICached<string> _cache;
private readonly ILogger _logger;
public SerialNumberProvider(ICacheManager cacheManager,
IDSMInfoProxy proxy,
Logger logger)
{
_proxy = proxy;
_cache = cacheManager.GetCache<string>(GetType());
_logger = logger;
}
public string GetSerialNumber(DownloadStationSettings settings)
{
try
{
return _cache.Get(settings.Host, () => GetHashedSerialNumber(settings), TimeSpan.FromMinutes(5));
}
catch (Exception ex)
{
_logger.Warn(ex, "Could not get the serial number from Download Station {0}:{1}", settings.Host, settings.Port);
throw;
}
}
private string GetHashedSerialNumber(DownloadStationSettings settings)
{
var serialNumber = _proxy.GetSerialNumber(settings);
return HashConverter.GetHash(serialNumber).ToHexString();
}
}
}

View File

@@ -12,6 +12,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.DownloadStation
@@ -21,11 +22,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected readonly IDownloadStationInfoProxy _dsInfoProxy;
protected readonly IDownloadStationTaskProxy _dsTaskProxy;
protected readonly ISharedFolderResolver _sharedFolderResolver;
protected readonly ISerialNumberProvider _serialNumberProvider;
protected readonly IDSMInfoProvider _dsmInfoProvider;
protected readonly IFileStationProxy _fileStationProxy;
public TorrentDownloadStation(ISharedFolderResolver sharedFolderResolver,
ISerialNumberProvider serialNumberProvider,
IDSMInfoProvider dsmInfoProvider,
IFileStationProxy fileStationProxy,
IDownloadStationInfoProxy dsInfoProxy,
IDownloadStationTaskProxy dsTaskProxy,
@@ -33,14 +34,15 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_dsInfoProxy = dsInfoProxy;
_dsTaskProxy = dsTaskProxy;
_fileStationProxy = fileStationProxy;
_sharedFolderResolver = sharedFolderResolver;
_serialNumberProvider = serialNumberProvider;
_dsmInfoProvider = dsmInfoProvider;
}
public override string Name => "Download Station";
@@ -53,7 +55,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override IEnumerable<DownloadClientItem> GetItems()
{
var torrents = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var serialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -94,7 +96,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
{
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent, serialNumber));
item.OutputPath = GetOutputPath(outputPath, torrent, serialNumber);
}
items.Add(item);
@@ -112,7 +114,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
};
}
catch (DownloadClientException e)
@@ -138,14 +140,16 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
var finalPath = fullPath + torrent.Title;
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
var finalPath = remotePath + torrent.Title;
return finalPath;
}
protected override string AddFromMagnetLink(RemoteEpisode remoteEpisode, string hash, string magnetLink)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromUrl(magnetLink, GetDownloadDirectory(), Settings);
@@ -164,7 +168,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected override string AddFromTorrentFile(RemoteEpisode remoteEpisode, string hash, string filename, byte[] fileContent)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
@@ -187,6 +191,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
failures.AddIfNotNull(TestConnection());
if (failures.Any()) return;
failures.AddIfNotNull(TestDSMVersion());
failures.AddIfNotNull(TestOutputPath());
failures.AddIfNotNull(TestGetTorrents());
}
@@ -299,7 +304,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{downloadDir}', are you sure you specified it correctly?"
};
}
@@ -330,7 +335,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
return ValidateVersion();
return TestProxiesVersions();
}
catch (DownloadClientAuthenticationException ex)
{
@@ -359,16 +364,40 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
protected ValidationFailure ValidateVersion()
protected ValidationFailure TestDSMVersion()
{
var info = _dsTaskProxy.GetApiInfo(Settings);
var dsmversion = _dsmInfoProvider.GetDSMVersion(Settings);
_logger.Debug("Download Station api version information: Min {0} - Max {1}", info.MinVersion, info.MaxVersion);
if (info.MinVersion > 2 || info.MaxVersion < 2)
if (dsmversion < new Version(6, 0, 0))
{
return new ValidationFailure(string.Empty, $"Download Station API version not supported, should be at least 2. It supports from {info.MinVersion} to {info.MaxVersion}");
return new NzbDroneValidationFailure(string.Empty, $"DSM Version {dsmversion} not fully supported. We recommend version 6.0.0 or above.") { IsWarning = true };
}
return null;
}
protected ValidationFailure TestProxiesVersions()
{
var dsmVersion = _dsmInfoProvider.GetDSMVersion(Settings);
var expectedVersions = new List<ExpectedVersion>()
{
new ExpectedVersion { Version = 2, Proxy = _dsTaskProxy },
new ExpectedVersion { Version = (dsmVersion >= new Version(6,0,0))? 2 : 1, Proxy = _fileStationProxy },
new ExpectedVersion { Version = 1, Proxy = _dsInfoProxy }
};
foreach (var expectedVersion in expectedVersions)
{
DiskStationApiInfo apiInfo = expectedVersion.Proxy.GetApiInfo(Settings);
_logger.Debug("{1} api version information: Min {1} - Max {2} - Expected {3}", apiInfo.Name, apiInfo.MinVersion, apiInfo.MaxVersion, expectedVersion.Version);
if (apiInfo.MinVersion > expectedVersion.Version || apiInfo.MaxVersion < expectedVersion.Version)
{
return new NzbDroneValidationFailure(string.Empty, $"{apiInfo.Name} API version not supported, should be at least {expectedVersion.Version}. It supports from {apiInfo.MinVersion} to {apiInfo.MaxVersion}");
}
}
return null;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -10,6 +10,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.DownloadStation.Proxies;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.DownloadStation
@@ -19,27 +20,27 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected readonly IDownloadStationInfoProxy _dsInfoProxy;
protected readonly IDownloadStationTaskProxy _dsTaskProxy;
protected readonly ISharedFolderResolver _sharedFolderResolver;
protected readonly ISerialNumberProvider _serialNumberProvider;
protected readonly IDSMInfoProvider _dsmInfoProvider;
protected readonly IFileStationProxy _fileStationProxy;
public UsenetDownloadStation(ISharedFolderResolver sharedFolderResolver,
ISerialNumberProvider serialNumberProvider,
IDSMInfoProvider dsmInfoProvider,
IFileStationProxy fileStationProxy,
IDownloadStationInfoProxy dsInfoProxy,
IDownloadStationTaskProxy dsTaskProxy,
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IValidateNzbs nzbValidationService,
IRemotePathMappingService remotePathMappingService,
Logger logger
)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_dsInfoProxy = dsInfoProxy;
_dsTaskProxy = dsTaskProxy;
_fileStationProxy = fileStationProxy;
_sharedFolderResolver = sharedFolderResolver;
_serialNumberProvider = serialNumberProvider;
_dsmInfoProvider = dsmInfoProvider;
}
public override string Name => "Download Station";
@@ -52,7 +53,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
public override IEnumerable<DownloadClientItem> GetItems()
{
var nzbTasks = GetTasks();
var serialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var serialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
var items = new List<DownloadClientItem>();
@@ -109,7 +110,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
if (item.Status == DownloadItemStatus.Completed || item.Status == DownloadItemStatus.Failed)
{
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, nzb, serialNumber));
item.OutputPath = GetOutputPath(outputPath, nzb, serialNumber);
}
items.Add(item);
@@ -122,7 +123,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
var fullPath = _sharedFolderResolver.RemapToFullPath(outputPath, Settings, serialNumber);
var remotePath = fullPath;
var remotePath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, fullPath);
var finalPath = remotePath + task.Title;
@@ -138,7 +139,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(path)) }
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(path)) }
};
}
catch (DownloadClientException e)
@@ -162,7 +163,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
protected override string AddFromNzbFile(RemoteEpisode remoteEpisode, string filename, byte[] fileContent)
{
var hashedSerialNumber = _serialNumberProvider.GetSerialNumber(Settings);
var hashedSerialNumber = _dsmInfoProvider.GetSerialNumber(Settings);
_dsTaskProxy.AddTaskFromData(fileContent, filename, GetDownloadDirectory(), Settings);
@@ -185,6 +186,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
failures.AddIfNotNull(TestConnection());
if (failures.Any()) return;
failures.AddIfNotNull(TestDSMVersion());
failures.AddIfNotNull(TestOutputPath());
failures.AddIfNotNull(TestGetNZB());
}
@@ -216,7 +218,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
return new NzbDroneValidationFailure(fieldName, $"Shared folder does not exist")
{
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{sharedFolder}', are you sure you specified it correctly?"
DetailedDescription = $"The Diskstation does not have a Shared Folder with the name '{downloadDir}', are you sure you specified it correctly?"
};
}
@@ -247,7 +249,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
{
try
{
return ValidateVersion();
return TestProxiesVersions();
}
catch (DownloadClientAuthenticationException ex)
{
@@ -268,24 +270,48 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
DetailedDescription = "Please verify the hostname and port."
};
}
return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
catch (Exception ex)
{
_logger.Error(ex, "Error testing Torrent Download Station");
return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}");
}
}
protected ValidationFailure ValidateVersion()
protected ValidationFailure TestDSMVersion()
{
var info = _dsTaskProxy.GetApiInfo(Settings);
var dsmversion = _dsmInfoProvider.GetDSMVersion(Settings);
_logger.Debug("Download Station api version information: Min {0} - Max {1}", info.MinVersion, info.MaxVersion);
if (info.MinVersion > 2 || info.MaxVersion < 2)
if (dsmversion < new Version(6, 0, 0))
{
return new ValidationFailure(string.Empty, $"Download Station API version not supported, should be at least 2. It supports from {info.MinVersion} to {info.MaxVersion}");
return new NzbDroneValidationFailure(string.Empty, $"DSM Version {dsmversion} not fully supported. We recommend version 6.0.0 or above.") { IsWarning = true };
}
return null;
}
protected ValidationFailure TestProxiesVersions()
{
var dsmVersion = _dsmInfoProvider.GetDSMVersion(Settings);
var expectedVersions = new List<ExpectedVersion>()
{
new ExpectedVersion { Version = 2, Proxy = _dsTaskProxy },
new ExpectedVersion { Version = (dsmVersion >= new Version(6,0,0))? 2 : 1, Proxy = _fileStationProxy },
new ExpectedVersion { Version = 1, Proxy = _dsInfoProxy }
};
foreach (var expectedVersion in expectedVersions)
{
DiskStationApiInfo apiInfo = expectedVersion.Proxy.GetApiInfo(Settings);
_logger.Debug("{1} api version information: Min {1} - Max {2} - Expected {3}", apiInfo.Name, apiInfo.MinVersion, apiInfo.MaxVersion, expectedVersion.Version);
if (apiInfo.MinVersion > expectedVersion.Version || apiInfo.MaxVersion < expectedVersion.Version)
{
return new NzbDroneValidationFailure(string.Empty, $"{apiInfo.Name} API version not supported, should be at least {expectedVersion.Version}. It supports from {apiInfo.MinVersion} to {apiInfo.MaxVersion}");
}
}
return null;
@@ -376,7 +402,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation
}
catch (Exception ex)
{
return new NzbDroneValidationFailure(string.Empty, "Failed to get the list of NZBs: " + ex.Message);
return new NzbDroneValidationFailure(string.Empty, $"Failed to get the list of NZBs: {ex.Message}");
}
}

View File

@@ -10,6 +10,7 @@ using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Hadouken.Models;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Hadouken
@@ -23,8 +24,9 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -44,7 +46,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
continue;
}
var outputPath = new OsPath(torrent.SavePath);
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
var eta = TimeSpan.FromSeconds(0);
if (torrent.DownloadRate > 0 && torrent.TotalSize > 0)
@@ -56,7 +58,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{
DownloadClient = Definition.Name,
DownloadId = torrent.InfoHash.ToUpper(),
OutputPath = new DownloadClientPath(Definition.Id, outputPath + torrent.Name),
OutputPath = outputPath + torrent.Name,
RemainingSize = torrent.TotalSize - torrent.DownloadedBytes,
RemainingTime = eta,
Title = torrent.Name,
@@ -117,7 +119,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
}
return status;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -10,6 +10,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Validation;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.NzbVortex
{
@@ -21,9 +22,9 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IValidateNzbs nzbValidationService,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -86,7 +87,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
break;
}
queueItem.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(vortexQueueItem, queueItem));
queueItem.OutputPath = GetOutputPath(vortexQueueItem, queueItem);
if (vortexQueueItem.State == NzbVortexStateType.PasswordRequest)
{
@@ -219,7 +220,7 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
private OsPath GetOutputPath(NzbVortexQueueItem vortexQueueItem, DownloadClientItem queueItem)
{
var outputPath = new OsPath(vortexQueueItem.DestinationPath);
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(vortexQueueItem.DestinationPath));
if (outputPath.FileName == vortexQueueItem.UiTitle)
{

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
@@ -10,6 +10,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Nzbget
@@ -24,9 +25,9 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IValidateNzbs nzbValidationService,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -121,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
historyItem.DownloadId = droneParameter == null ? item.Id.ToString() : droneParameter.Value.ToString();
historyItem.Title = item.Name;
historyItem.TotalSize = MakeInt64(item.FileSizeHi, item.FileSizeLo);
historyItem.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(item.DestDir));
historyItem.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(item.DestDir));
historyItem.Category = item.Category;
historyItem.Message = $"PAR Status: {item.ParStatus} - Unpack Status: {item.UnpackStatus} - Move Status: {item.MoveStatus} - Script Status: {item.ScriptStatus} - Delete Status: {item.DeleteStatus} - Mark Status: {item.MarkStatus}";
historyItem.Status = DownloadItemStatus.Completed;
@@ -206,7 +207,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
if (category != null)
{
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(category.DestDir)) };
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(category.DestDir)) };
}
return status;

View File

@@ -8,6 +8,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Parser.Model;
@@ -20,8 +21,9 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
public Pneumatic(IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(configService, diskProvider, logger)
: base(configService, diskProvider, remotePathMappingService, logger)
{
_httpClient = httpClient;
}
@@ -80,7 +82,7 @@ namespace NzbDrone.Core.Download.Clients.Pneumatic
TotalSize = _diskProvider.GetFileSize(file),
OutputPath = new DownloadClientPath(Definition.Id, new OsPath(file))
OutputPath = new OsPath(file)
};
if (_diskProvider.IsFileLocked(file))

View File

@@ -11,6 +11,7 @@ using NzbDrone.Core.Validation;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.QBittorrent
{
@@ -23,8 +24,9 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -107,17 +109,16 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
item.RemainingSize = (long)(torrent.Size * (1.0 - torrent.Progress));
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
var outputPath = new OsPath(torrent.SavePath);
if (!outputPath.IsEmpty && outputPath.FileName != torrent.Name)
{
outputPath += torrent.Name;
}
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.SavePath));
// Avoid removing torrents that haven't reached the global max ratio.
// Removal also requires the torrent to be paused, in case a higher max ratio was set on the torrent itself (which is not exposed by the api).
item.CanMoveFiles = item.CanBeRemoved = (!config.MaxRatioEnabled || config.MaxRatio <= torrent.Ratio) && torrent.State == "pausedUP";
if (!item.OutputPath.IsEmpty && item.OutputPath.FileName != torrent.Name)
{
item.OutputPath += torrent.Name;
}
switch (torrent.State)
{
@@ -175,7 +176,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) }
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) }
};
}

View File

@@ -21,7 +21,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
public QBittorrentSettings()
{
Host = "localhost";
Port = 8080;
Port = 9091;
TvCategory = "tv-sonarr";
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
@@ -10,6 +10,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Validation;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Sabnzbd
{
@@ -21,9 +22,9 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IValidateNzbs nzbValidationService,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(httpClient, configService, diskProvider, nzbValidationService, logger)
: base(httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -161,23 +162,24 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
historyItem.Status = DownloadItemStatus.Downloading;
}
var outputPath = new OsPath(sabHistoryItem.Storage);
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(sabHistoryItem.Storage));
if (!outputPath.IsEmpty)
{
historyItem.OutputPath = outputPath;
var parent = outputPath.Directory;
while (!parent.IsEmpty)
{
if (parent.FileName == sabHistoryItem.Title)
{
outputPath = parent;
historyItem.OutputPath = parent;
}
parent = parent.Directory;
}
historyItem.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
}
historyItems.Add(historyItem);
}
@@ -258,7 +260,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
if (category != null)
{
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, category.FullPath) };
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, category.FullPath) };
}
return status;

View File

@@ -6,6 +6,7 @@ using NzbDrone.Core.Configuration;
using NLog;
using FluentValidation.Results;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Transmission
{
@@ -16,8 +17,9 @@ namespace NzbDrone.Core.Download.Clients.Transmission
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
}

View File

@@ -10,6 +10,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Download.Clients.Transmission
@@ -23,8 +24,9 @@ namespace NzbDrone.Core.Download.Clients.Transmission
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
}
@@ -52,6 +54,8 @@ namespace NzbDrone.Core.Download.Clients.Transmission
if (!directories.Contains(Settings.TvCategory)) continue;
}
outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, outputPath);
var item = new DownloadClientItem();
item.DownloadId = torrent.HashString.ToUpper();
item.Category = Settings.TvCategory;
@@ -59,7 +63,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
item.DownloadClient = Definition.Name;
item.OutputPath = new DownloadClientPath(Definition.Id, GetOutputPath(outputPath, torrent));
item.OutputPath = GetOutputPath(outputPath, torrent);
item.TotalSize = torrent.TotalSize;
item.RemainingSize = torrent.LeftUntilDone;
if (torrent.Eta >= 0)
@@ -118,7 +122,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
return new DownloadClientInfo
{
IsLocalhost = Settings.Host == "127.0.0.1" || Settings.Host == "localhost",
OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, new OsPath(destDir)) }
OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(destDir)) }
};
}

View File

@@ -5,6 +5,7 @@ using NzbDrone.Common.Http;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Download.Clients.Transmission;
using NzbDrone.Core.MediaFiles.TorrentInfo;
using NzbDrone.Core.RemotePathMappings;
namespace NzbDrone.Core.Download.Clients.Vuze
{
@@ -17,8 +18,9 @@ namespace NzbDrone.Core.Download.Clients.Vuze
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(proxy, torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
}

View File

@@ -13,6 +13,7 @@ using FluentValidation.Results;
using NzbDrone.Core.Download.Clients.rTorrent;
using NzbDrone.Core.Exceptions;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
namespace NzbDrone.Core.Download.Clients.RTorrent
@@ -27,9 +28,10 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
IRTorrentDirectoryValidator rTorrentDirectoryValidator,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
_rTorrentDirectoryValidator = rTorrentDirectoryValidator;
@@ -98,7 +100,7 @@ namespace NzbDrone.Core.Download.Clients.RTorrent
item.DownloadClient = Definition.Name;
item.Title = torrent.Name;
item.DownloadId = torrent.Hash;
item.OutputPath = new DownloadClientPath(Definition.Id, new OsPath(torrent.Path));
item.OutputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.Path));
item.TotalSize = torrent.TotalSize;
item.RemainingSize = torrent.RemainingSize;
item.Category = torrent.Category;

View File

@@ -11,6 +11,7 @@ using NzbDrone.Core.Validation;
using FluentValidation.Results;
using System.Net;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Common.Cache;
namespace NzbDrone.Core.Download.Clients.UTorrent
@@ -26,8 +27,9 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
IHttpClient httpClient,
IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, logger)
: base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger)
{
_proxy = proxy;
@@ -97,13 +99,16 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
item.RemainingTime = TimeSpan.FromSeconds(torrent.Eta);
}
var outputPath = new OsPath(torrent.RootDownloadPath);
var outputPath = _remotePathMappingService.RemapRemoteToLocal(Settings.Host, new OsPath(torrent.RootDownloadPath));
if (outputPath != null && outputPath.FileName != torrent.Name)
if (outputPath == null || outputPath.FileName == torrent.Name)
{
outputPath += torrent.Name;
item.OutputPath = outputPath;
}
else
{
item.OutputPath = outputPath + torrent.Name;
}
item.OutputPath = new DownloadClientPath(Definition.Id, outputPath);
if (torrent.Status.HasFlag(UTorrentTorrentStatus.Error))
{
@@ -204,7 +209,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
if (!destDir.IsEmpty)
{
status.OutputRootFolders = new List<DownloadClientPath> { new DownloadClientPath(Definition.Id, destDir) };
status.OutputRootFolders = new List<OsPath> { _remotePathMappingService.RemapRemoteToLocal(Settings.Host, destDir) };
}
return status;

View File

@@ -1,4 +1,4 @@
using FluentValidation;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@@ -22,7 +22,7 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
public UTorrentSettings()
{
Host = "localhost";
Port = 8080;
Port = 9091;
TvCategory = "tv-sonarr";
}

View File

@@ -8,6 +8,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.RemotePathMappings;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@@ -18,6 +19,7 @@ namespace NzbDrone.Core.Download
{
protected readonly IConfigService _configService;
protected readonly IDiskProvider _diskProvider;
protected readonly IRemotePathMappingService _remotePathMappingService;
protected readonly Logger _logger;
public abstract string Name { get; }
@@ -34,12 +36,14 @@ namespace NzbDrone.Core.Download
protected TSettings Settings => (TSettings)Definition.Settings;
protected DownloadClientBase(IConfigService configService,
IDiskProvider diskProvider,
protected DownloadClientBase(IConfigService configService,
IDiskProvider diskProvider,
IRemotePathMappingService remotePathMappingService,
Logger logger)
{
_configService = configService;
_diskProvider = diskProvider;
_remotePathMappingService = remotePathMappingService;
_logger = logger;
}
@@ -72,9 +76,6 @@ namespace NzbDrone.Core.Download
return;
}
// FIXME: Doesn't work if remote.
throw new NotSupportedException();
/*
if (item.OutputPath.IsEmpty)
{
_logger.Trace("[{0}] Doesn't have an outputPath, skipping delete data.", item.Title);
@@ -103,7 +104,7 @@ namespace NzbDrone.Core.Download
catch (Exception ex)
{
_logger.Warn(ex, string.Format("[{0}] Error occurred while trying to delete data from '{1}'.", item.Title, item.OutputPath));
}*/
}
}
public ValidationResult Test()

Some files were not shown because too many files have changed in this diff Show More