From 0ca70a3197e9854b0288b1eee0b1de91885b28f2 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 12 Apr 2019 19:21:49 -0700 Subject: [PATCH] Fixed: Long path support on Windows --- 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..ef4bd3f7c --- /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 0bcd07088..45e9da18c 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -92,6 +92,7 @@ + diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index bda04da2d..dc6e50753 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; @@ -28,6 +29,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 2f4a22ce8..e5a829c44 100644 --- a/src/NzbDrone.Host/app.config +++ b/src/NzbDrone.Host/app.config @@ -10,7 +10,6 @@ -