From 7b3edb8737fed4b73fe080ca12b655703b331508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Sun, 19 May 2013 23:56:40 -0400 Subject: [PATCH 1/2] Allow capitalising change on virtual folders --- MediaBrowser.Api/Library/LibraryHelpers.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs index 12b9d478f..67e1160f7 100644 --- a/MediaBrowser.Api/Library/LibraryHelpers.cs +++ b/MediaBrowser.Api/Library/LibraryHelpers.cs @@ -77,9 +77,12 @@ namespace MediaBrowser.Api.Library if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath)) { - throw new ArgumentException("There is already a media collection with the name " + newPath + "."); + //Create an unique name + var temporaryName = Guid.NewGuid().ToString(); + var temporaryPath = Path.Combine(rootFolderPath, temporaryName); + Directory.Move(currentPath,temporaryPath); + currentPath = temporaryPath; } - Directory.Move(currentPath, newPath); } From ac569421a98fed4b47dbff941f2ca29a773d188a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Mon, 20 May 2013 01:45:54 -0400 Subject: [PATCH 2/2] Fix move condition --- MediaBrowser.Api/Library/LibraryHelpers.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs index 67e1160f7..ff0915d78 100644 --- a/MediaBrowser.Api/Library/LibraryHelpers.cs +++ b/MediaBrowser.Api/Library/LibraryHelpers.cs @@ -76,6 +76,11 @@ namespace MediaBrowser.Api.Library } if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath)) + { + throw new ArgumentException("There is already a media collection with the name " + newPath + "."); + } + //Only make a two-phase move when changing capitalization + if (string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase)) { //Create an unique name var temporaryName = Guid.NewGuid().ToString(); @@ -83,6 +88,7 @@ namespace MediaBrowser.Api.Library Directory.Move(currentPath,temporaryPath); currentPath = temporaryPath; } + Directory.Move(currentPath, newPath); }