From e086eebb71f7d950750e7a21ec4c059f6f352458 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Wed, 30 Mar 2022 20:10:12 -0600 Subject: [PATCH] Merge pull request #7525 from 1337joe/fix-duplicate-library-media-paths (cherry picked from commit bebe1808ce529cff867b5b0c207542aadc9aedff) Signed-off-by: crobibero --- Emby.Server.Implementations/Library/LibraryManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index a9428ae9bc..d6754ad4a8 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -2840,10 +2840,12 @@ namespace Emby.Server.Implementations.Library var existingNameCount = 1; // first numbered name will be 2 var virtualFolderPath = Path.Combine(rootFolderPath, name); + var originalName = name; while (Directory.Exists(virtualFolderPath)) { existingNameCount++; - virtualFolderPath = Path.Combine(rootFolderPath, name + " " + existingNameCount); + name = originalName + existingNameCount; + virtualFolderPath = Path.Combine(rootFolderPath, name); } var mediaPathInfos = options.PathInfos;