mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-16 21:35:04 -04:00
Compare commits
6 Commits
v2.1.5.521
...
sql-fallba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab4d80faa6 | ||
|
|
a2afcff6df | ||
|
|
e4fb36e08f | ||
|
|
ff22fdf7d3 | ||
|
|
b3d46465ae | ||
|
|
eb57d20545 |
@@ -9,7 +9,7 @@ variables:
|
|||||||
testsFolder: './_tests'
|
testsFolder: './_tests'
|
||||||
yarnCacheFolder: $(Pipeline.Workspace)/.yarn
|
yarnCacheFolder: $(Pipeline.Workspace)/.yarn
|
||||||
nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages
|
nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages
|
||||||
majorVersion: '2.1.5'
|
majorVersion: '2.3.0'
|
||||||
minorVersion: $[counter('minorVersion', 1)]
|
minorVersion: $[counter('minorVersion', 1)]
|
||||||
prowlarrVersion: '$(majorVersion).$(minorVersion)'
|
prowlarrVersion: '$(majorVersion).$(minorVersion)'
|
||||||
buildName: '$(Build.SourceBranchName).$(prowlarrVersion)'
|
buildName: '$(Build.SourceBranchName).$(prowlarrVersion)'
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ namespace NzbDrone.Common.Composition
|
|||||||
static AssemblyLoader()
|
static AssemblyLoader()
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler);
|
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ContainerResolveEventHandler);
|
||||||
RegisterSQLiteResolver();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IList<Assembly> Load(IList<string> assemblyNames)
|
public static IList<Assembly> Load(IList<string> assemblyNames)
|
||||||
@@ -23,6 +22,10 @@ namespace NzbDrone.Common.Composition
|
|||||||
toLoad.Add("Prowlarr.Common");
|
toLoad.Add("Prowlarr.Common");
|
||||||
toLoad.Add(OsInfo.IsWindows ? "Prowlarr.Windows" : "Prowlarr.Mono");
|
toLoad.Add(OsInfo.IsWindows ? "Prowlarr.Windows" : "Prowlarr.Mono");
|
||||||
|
|
||||||
|
var toRegisterResolver = new List<string> { "System.Data.SQLite" };
|
||||||
|
toRegisterResolver.AddRange(assemblyNames.Intersect(new[] { "Prowlarr.Core" }));
|
||||||
|
RegisterNativeResolver(toRegisterResolver);
|
||||||
|
|
||||||
var startupPath = AppDomain.CurrentDomain.BaseDirectory;
|
var startupPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
|
||||||
return toLoad
|
return toLoad
|
||||||
@@ -43,27 +46,46 @@ namespace NzbDrone.Common.Composition
|
|||||||
return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath);
|
return AssemblyLoadContext.Default.LoadFromAssemblyPath(assemblyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterSQLiteResolver()
|
public static void RegisterNativeResolver(IEnumerable<string> assemblyNames)
|
||||||
{
|
{
|
||||||
// This ensures we look for sqlite3 using libsqlite3.so.0 on Linux and not libsqlite3.so which
|
foreach (var name in assemblyNames)
|
||||||
// is less likely to exist.
|
{
|
||||||
var sqliteAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(
|
// This ensures we look for sqlite3 using libsqlite3.so.0 on Linux and not libsqlite3.so which
|
||||||
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "System.Data.SQLite.dll"));
|
// is less likely to exist.
|
||||||
|
var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(
|
||||||
|
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{name}.dll"));
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NativeLibrary.SetDllImportResolver(sqliteAssembly, LoadSqliteNativeLib);
|
NativeLibrary.SetDllImportResolver(assembly, LoadNativeLib);
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException)
|
catch (InvalidOperationException)
|
||||||
{
|
{
|
||||||
// This can only be set once per assembly
|
// This can only be set once per assembly
|
||||||
// Catch required for NzbDrone.Host tests
|
// Catch required for NzbDrone.Host tests
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntPtr LoadSqliteNativeLib(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
|
private static IntPtr LoadNativeLib(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
|
||||||
{
|
{
|
||||||
var mappedName = OsInfo.IsLinux && libraryName == "sqlite3" ? "libsqlite3.so.0" : libraryName;
|
ArgumentException.ThrowIfNullOrWhiteSpace(libraryName);
|
||||||
|
|
||||||
|
var mappedName = libraryName;
|
||||||
|
|
||||||
|
if (libraryName is "sqlite3" or "e_sqlite3")
|
||||||
|
{
|
||||||
|
if (OsInfo.IsLinux)
|
||||||
|
{
|
||||||
|
if (NativeLibrary.TryLoad(libraryName, assembly, dllImportSearchPath, out var libHandle))
|
||||||
|
{
|
||||||
|
return libHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
mappedName = "libsqlite3.so.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
|
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -424,8 +424,8 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
|||||||
}
|
}
|
||||||
catch (HttpException ex)
|
catch (HttpException ex)
|
||||||
{
|
{
|
||||||
_logger.Debug("qbitTorrent authentication failed.");
|
_logger.Debug(ex, "qbitTorrent authentication failed.");
|
||||||
if (ex.Response.StatusCode == HttpStatusCode.Forbidden)
|
if (ex.Response.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
|
||||||
{
|
{
|
||||||
throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.", ex);
|
throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.", ex);
|
||||||
}
|
}
|
||||||
@@ -437,9 +437,9 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
|
|||||||
throw new DownloadClientUnavailableException("Failed to connect to qBittorrent, please check your settings.", ex);
|
throw new DownloadClientUnavailableException("Failed to connect to qBittorrent, please check your settings.", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.Content != "Ok.")
|
// returns "Fails." on bad login
|
||||||
|
if (response.Content.IsNotNullOrWhiteSpace() && response.Content != "Ok.")
|
||||||
{
|
{
|
||||||
// returns "Fails." on bad login
|
|
||||||
_logger.Debug("qbitTorrent authentication failed.");
|
_logger.Debug("qbitTorrent authentication failed.");
|
||||||
throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.");
|
throw new DownloadClientAuthenticationException("Failed to authenticate with qBittorrent.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using DryIoc;
|
using DryIoc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@@ -31,6 +32,7 @@ using Prowlarr.Http.ClientSchema;
|
|||||||
using Prowlarr.Http.ErrorManagement;
|
using Prowlarr.Http.ErrorManagement;
|
||||||
using Prowlarr.Http.Frontend;
|
using Prowlarr.Http.Frontend;
|
||||||
using Prowlarr.Http.Middleware;
|
using Prowlarr.Http.Middleware;
|
||||||
|
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
|
||||||
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
|
||||||
|
|
||||||
namespace NzbDrone.Host
|
namespace NzbDrone.Host
|
||||||
@@ -59,8 +61,9 @@ namespace NzbDrone.Host
|
|||||||
services.Configure<ForwardedHeadersOptions>(options =>
|
services.Configure<ForwardedHeadersOptions>(options =>
|
||||||
{
|
{
|
||||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
|
||||||
options.KnownNetworks.Clear();
|
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("10.0.0.0"), 8));
|
||||||
options.KnownProxies.Clear();
|
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("172.16.0.0"), 12));
|
||||||
|
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("192.168.0.0"), 16));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddRouting(options => options.LowercaseUrls = true);
|
services.AddRouting(options => options.LowercaseUrls = true);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace NzbDrone.Test.Common.AutoMoq
|
|||||||
|
|
||||||
if (behavior != MockBehavior.Default && mock.Behavior == MockBehavior.Default)
|
if (behavior != MockBehavior.Default && mock.Behavior == MockBehavior.Default)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Unable to change be behaviour of a an existing mock.");
|
throw new InvalidOperationException("Unable to change be behaviour of an existing mock.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return mock;
|
return mock;
|
||||||
@@ -139,7 +139,7 @@ namespace NzbDrone.Test.Common.AutoMoq
|
|||||||
|
|
||||||
LoadPlatformLibrary();
|
LoadPlatformLibrary();
|
||||||
|
|
||||||
AssemblyLoader.RegisterSQLiteResolver();
|
AssemblyLoader.RegisterNativeResolver(new[] { "System.Data.SQLite", "Prowlarr.Core" });
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mock<T> TheRegisteredMockForThisType<T>(Type type)
|
private Mock<T> TheRegisteredMockForThisType<T>(Type type)
|
||||||
|
|||||||
Reference in New Issue
Block a user