Skip to content
Merged

Sync #80

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@

<!-- Standard testing packages -->
<ItemGroup Condition="'$(TestProject)'=='true'">
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.4" />
<PackageReference Include="coverlet.collector" Version="10.0.1" />
<PackageReference Include="GitHubActionsTestLogger" Version="3.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Api.Test/Radarr.Api.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ProjectReference Include="..\Radarr.Http\Radarr.Http.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="coverlet.collector" Version="6.0.4">
<PackageReference Update="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions src/NzbDrone.Automation.Test/Radarr.Automation.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<TargetFrameworks>net10.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Selenium.Support" Version="4.44.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="148.0.7778.17800" />
<PackageReference Include="Selenium.Support" Version="4.46.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="150.0.7871.12400" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Test.Common\Radarr.Test.Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="coverlet.collector" Version="6.0.4">
<PackageReference Update="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions src/NzbDrone.Common.Test/Http/HttpClientFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,16 @@ public async Task should_parse_malformed_cloudflare_cookie(string culture)
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
try
{
// the date is bad in the below - should be 13-Jul-2026
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly";
// the date is bad in the below - should be 16-Jul-2046
var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 16-Jul-46 16:19:50 GMT; path=/; HttpOnly";
var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers")
.AddQueryParam("Set-Cookie", malformedCookie)
.Build();

requestSet.AllowAutoRedirect = false;
requestSet.StoreResponseCookie = true;

var responseSet = await Subject.GetAsync(requestSet);
await Subject.GetAsync(requestSet);

var request = new HttpRequest($"https://{_httpBinHost}/get");

Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Common.Test/Radarr.Common.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ProjectReference Include="..\NzbDrone.Test.Dummy\Radarr.Test.Dummy.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="coverlet.collector" Version="6.0.4">
<PackageReference Update="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
41 changes: 19 additions & 22 deletions src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ public ManagedHttpDispatcher(IHttpProxySettingsProvider proxySettingsProvider,

public async Task<HttpResponse> GetResponseAsync(HttpRequest request, CookieContainer cookies)
{
var requestMessage = new HttpRequestMessage(request.Method, (Uri)request.Url)
{
Version = HttpVersion.Version20,
VersionPolicy = HttpVersionPolicy.RequestVersionOrLower
};
using var requestMessage = new HttpRequestMessage(request.Method, (Uri)request.Url);
requestMessage.Version = HttpVersion.Version20;
requestMessage.VersionPolicy = HttpVersionPolicy.RequestVersionOrLower;
requestMessage.Headers.UserAgent.ParseAdd(_userAgentBuilder.GetUserAgent(request.UseSimplifiedUserAgent));
requestMessage.Headers.ConnectionClose = !request.ConnectionKeepAlive;

Expand Down Expand Up @@ -113,31 +111,30 @@ public async Task<HttpResponse> GetResponseAsync(HttpRequest request, CookieCont
try
{
using var responseMessage = await httpClient.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, cts.Token);
{
byte[] data = null;

try
byte[] data = null;

try
{
if (request.ResponseStream != null && responseMessage.StatusCode == HttpStatusCode.OK)
{
if (request.ResponseStream != null && responseMessage.StatusCode == HttpStatusCode.OK)
{
await responseMessage.Content.CopyToAsync(request.ResponseStream, null, cts.Token);
}
else
{
data = await responseMessage.Content.ReadAsByteArrayAsync(cts.Token);
}
await responseMessage.Content.CopyToAsync(request.ResponseStream, null, cts.Token);
}
catch (Exception ex)
else
{
throw new WebException("Failed to read complete http response", ex, WebExceptionStatus.ReceiveFailure, null);
data = await responseMessage.Content.ReadAsByteArrayAsync(cts.Token);
}
}
catch (Exception ex)
{
throw new WebException("Failed to read complete http response", ex, WebExceptionStatus.ReceiveFailure, null);
}

var headers = responseMessage.Headers.ToNameValueCollection();
var headers = responseMessage.Headers.ToNameValueCollection();

headers.Add(responseMessage.Content.Headers.ToNameValueCollection());
headers.Add(responseMessage.Content.Headers.ToNameValueCollection());

return new HttpResponse(request, new HttpHeader(headers), data, responseMessage.StatusCode, responseMessage.Version);
}
return new HttpResponse(request, new HttpHeader(headers), data, responseMessage.StatusCode, responseMessage.Version);
}
catch (OperationCanceledException ex) when (cts.IsCancellationRequested)
{
Expand Down
6 changes: 4 additions & 2 deletions src/NzbDrone.Common/Http/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ public override string ToString()
public class HttpResponse<T> : HttpResponse
where T : new()
{
private readonly Lazy<T> _resource;

public HttpResponse(HttpResponse response)
: base(response.Request, response.Headers, response.ResponseData, response.StatusCode, response.Version)
{
Resource = Json.Deserialize<T>(response.Content);
_resource = new Lazy<T>(() => Json.Deserialize<T>(response.Content));
}

public T Resource { get; private set; }
public T Resource => _resource.Value;
}
}
8 changes: 4 additions & 4 deletions src/NzbDrone.Common/Radarr.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="5.4.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.10" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="10.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="NLog" Version="5.5.1" />
<PackageReference Include="NLog.Layouts.ClefJsonLayout" Version="1.0.5" />
<PackageReference Include="Npgsql" Version="10.0.3" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="SourceGear.sqlite3" Version="3.50.4.5" />
<PackageReference Include="SourceGear.sqlite3" Version="3.53.3" />
<PackageReference Include="System.Data.SQLite" Version="2.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.6.2" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.8" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="10.0.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="EnsureThat\Resources\ExceptionMessages.Designer.cs">
Expand Down
22 changes: 7 additions & 15 deletions src/NzbDrone.Core.Test/MediaCoverTests/MediaCoverServiceFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,29 @@ public void Setup()

_movie = Builder<Movie>.CreateNew()
.With(v => v.Id = 2)
.With(v => v.MovieMetadata.Value.Images = new List<MediaCover.MediaCover> { new MediaCover.MediaCover(MediaCoverTypes.Poster, "") })
.With(v => v.MovieMetadata.Value.Images = new List<MediaCover.MediaCover> { new(MediaCoverTypes.Poster, "") })
.Build();

Mocker.GetMock<IMovieService>().Setup(m => m.GetMovie(It.Is<int>(id => id == _movie.Id))).Returns(_movie);
}

[Test]
public void should_convert_cover_urls_to_local()
{
var covers = new List<MediaCover.MediaCover>
{
new MediaCover.MediaCover { CoverType = MediaCoverTypes.Banner }
};

Mocker.GetMock<IDiskProvider>().Setup(c => c.FileGetLastWrite(It.IsAny<string>()))
.Returns(new DateTime(1234));

Mocker.GetMock<IDiskProvider>().Setup(c => c.FileExists(It.IsAny<string>()))
.Returns(true);
{
new() { CoverType = MediaCoverTypes.Banner, RemoteUrl = "https://artworks.examples.com/banners/1.jpg" }
};

Subject.ConvertToLocalUrls(12, covers);

covers.Single().Url.Should().Be("/MediaCover/12/banner.jpg?lastWrite=1234");
covers.Single().Url.Should().Be("/MediaCover/12/banner.jpg?h=a6210a45e2b93963ad9e");
}

[Test]
public void should_convert_media_urls_to_local_without_time_if_file_doesnt_exist()
public void should_convert_media_urls_to_local_without_hash_if_remote_url_is_empty()
{
var covers = new List<MediaCover.MediaCover>
{
new MediaCover.MediaCover { CoverType = MediaCoverTypes.Banner }
new() { CoverType = MediaCoverTypes.Banner }
};

Subject.ConvertToLocalUrls(12, covers);
Expand Down
2 changes: 1 addition & 1 deletion src/NzbDrone.Core.Test/Radarr.Core.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Folder Include="IndexerTests\TorrentleechTests\" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="coverlet.collector" Version="6.0.4">
<PackageReference Update="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class IndexerFlagSpecificationValidator : AbstractValidator<IndexerFlagSp
public IndexerFlagSpecificationValidator()
{
RuleFor(c => c.Value).NotEmpty();
RuleFor(c => c.Value).Custom((qualityValue, context) =>
RuleFor(c => c.Value).Custom((flag, context) =>
{
if (!Enum.IsDefined(typeof(IndexerFlags), qualityValue))
if (!Enum.IsDefined(typeof(IndexerFlags), flag))
{
context.AddFailure($"Invalid indexer flag condition value: {qualityValue}");
context.AddFailure($"Invalid indexer flag condition value: {flag}");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ public class QualityModifierSpecificationValidator : AbstractValidator<QualityMo
{
public QualityModifierSpecificationValidator()
{
RuleFor(c => c.Value).NotEmpty();
RuleFor(c => c.Value).Custom((qualityValue, context) =>
RuleFor(c => c.Value).Custom((value, context) =>
{
if (!Enum.IsDefined(typeof(Modifier), qualityValue))
if (!Enum.IsDefined(typeof(Modifier), value))
{
context.AddFailure(string.Format("Invalid quality modifier condition value: {0}", qualityValue));
context.AddFailure($"Invalid quality modifier condition value: {value}");
}
});
}
}

public class QualityModifierSpecification : CustomFormatSpecificationBase
{
private static readonly QualityModifierSpecificationValidator Validator = new QualityModifierSpecificationValidator();
private static readonly QualityModifierSpecificationValidator Validator = new();

public override int Order => 7;
public override string ImplementationName => "Quality Modifier";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Parser;
Expand All @@ -9,13 +10,19 @@ public class ResolutionSpecificationValidator : AbstractValidator<ResolutionSpec
{
public ResolutionSpecificationValidator()
{
RuleFor(c => c.Value).NotEmpty();
RuleFor(c => c.Value).Custom((value, context) =>
{
if (!Enum.IsDefined(typeof(Resolution), value))
{
context.AddFailure($"Invalid resolution condition value: {value}");
}
});
}
}

public class ResolutionSpecification : CustomFormatSpecificationBase
{
private static readonly ResolutionSpecificationValidator Validator = new ResolutionSpecificationValidator();
private static readonly ResolutionSpecificationValidator Validator = new();

public override int Order => 6;
public override string ImplementationName => "Resolution";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Qualities;
Expand All @@ -9,13 +10,19 @@ public class SourceSpecificationValidator : AbstractValidator<SourceSpecificatio
{
public SourceSpecificationValidator()
{
RuleFor(c => c.Value).NotEmpty();
RuleFor(c => c.Value).Custom((value, context) =>
{
if (!Enum.IsDefined(typeof(QualitySource), value))
{
context.AddFailure($"Invalid source condition value: {value}");
}
});
}
}

public class SourceSpecification : CustomFormatSpecificationBase
{
private static readonly SourceSpecificationValidator Validator = new SourceSpecificationValidator();
private static readonly SourceSpecificationValidator Validator = new();

public override int Order => 5;
public override string ImplementationName => "Source";
Expand Down
8 changes: 6 additions & 2 deletions src/NzbDrone.Core/Datastore/BasicRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,10 @@ public void UpdateMany(IList<TModel> models)
}

using (var conn = _database.OpenConnection())
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
UpdateFields(conn, null, models, _properties);
UpdateFields(conn, tran, models, _properties);
tran.Commit();
}
}

Expand Down Expand Up @@ -371,8 +373,10 @@ public void SetFields(IList<TModel> models, params Expression<Func<TModel, objec
var propertiesToUpdate = properties.Select(x => x.GetMemberName()).ToList();

using (var conn = _database.OpenConnection())
using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
{
UpdateFields(conn, null, models, propertiesToUpdate);
UpdateFields(conn, tran, models, propertiesToUpdate);
tran.Commit();
}

foreach (var model in models)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public UpgradeableRejectReason IsUpgradable(QualityProfile qualityProfile, Quali

if (newFormatScore < currentFormatScore + qualityProfile.MinUpgradeFormatScore)
{
_logger.Debug("New item's custom formats [{0}] ({1}) do not meet minimum custom format score increment of {3} required for upgrade, skipping. Existing: [{4}] ({5}).",
_logger.Debug("New item's custom formats [{0}] ({1}) do not meet minimum custom format score increment of {2} required for upgrade, skipping. Existing: [{3}] ({4}).",
newCustomFormats.ConcatToString(),
newFormatScore,
qualityProfile.MinUpgradeFormatScore,
Expand Down
Loading
Loading