From a9b2635cb0ca7018d5cd5d68f37ef09d59e0d7d2 Mon Sep 17 00:00:00 2001 From: Alan Collins Date: Fri, 28 Jan 2022 17:02:13 -0600 Subject: [PATCH] Adjusted the Windows LongPath support check for valid segment lengths (cherry picked from commit 52c6bc5549ab998ccc018d138c55f8f924eed6d3) --- src/NzbDrone.Common/Disk/LongPathSupport.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Disk/LongPathSupport.cs b/src/NzbDrone.Common/Disk/LongPathSupport.cs index f971175a6..e001c96aa 100644 --- a/src/NzbDrone.Common/Disk/LongPathSupport.cs +++ b/src/NzbDrone.Common/Disk/LongPathSupport.cs @@ -31,7 +31,10 @@ namespace NzbDrone.Common.Disk { try { - Path.GetDirectoryName($@"C:\{new string('a', 300)}\ab"); + // Windows paths can be up to 32,767 characters long, but each component of the path must be less than 255. + // If the OS does not have Long Path enabled, then the following will throw an exception + // ref: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation + Path.GetDirectoryName($@"C:\{new string('a', 254)}\{new string('a', 254)}"); MAX_PATH = 4096; } catch