From b5d502bd5dc67393594e5e50c202e63d88d0110c Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 10 May 2019 22:54:41 -0400 Subject: [PATCH] Fixed: Long Path Support on Mono and .Net --- src/NzbDrone.Common/Disk/LongPathSupport.cs | 15 +++++++++++++++ src/NzbDrone.Common/NzbDrone.Common.csproj | 1 + src/NzbDrone.Host/Bootstrap.cs | 3 +++ src/NzbDrone.Host/app.config | 1 - 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/NzbDrone.Common/Disk/LongPathSupport.cs diff --git a/src/NzbDrone.Common/Disk/LongPathSupport.cs b/src/NzbDrone.Common/Disk/LongPathSupport.cs new file mode 100644 index 000000000..916123f8d --- /dev/null +++ b/src/NzbDrone.Common/Disk/LongPathSupport.cs @@ -0,0 +1,15 @@ +using System; + +namespace NzbDrone.Common.Disk +{ + public static class LongPathSupport + { + public static void Enable() + { + // Mono has an issue with enabling long path support via app.config. + // This works for both mono and .net on Windows. + AppContext.SetSwitch("Switch.System.IO.UseLegacyPathHandling", false); + AppContext.SetSwitch("Switch.System.IO.BlockLongPaths", false); + } + } +} diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 21388fb7f..7942d2188 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -106,6 +106,7 @@ + diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 28a9be29b..a562f44e8 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -3,6 +3,7 @@ using System.Reflection; using System.Threading; using NLog; using NzbDrone.Common.Composition; +using NzbDrone.Common.Disk; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Exceptions; using NzbDrone.Common.Instrumentation; @@ -32,6 +33,8 @@ namespace NzbDrone.Host throw new TerminateApplicationException("Missing system requirements"); } + LongPathSupport.Enable(); + _container = MainAppContainerBuilder.BuildContainer(startupContext); _container.Resolve().Register(); _container.Resolve().Write(); diff --git a/src/NzbDrone.Host/app.config b/src/NzbDrone.Host/app.config index cdde64137..dfc9fa3f9 100644 --- a/src/NzbDrone.Host/app.config +++ b/src/NzbDrone.Host/app.config @@ -10,7 +10,6 @@ -