浏览代码

Fix move condition

Luis Miguel Almánzar 12 年之前
父节点
当前提交
ac569421a9
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      MediaBrowser.Api/Library/LibraryHelpers.cs

+ 6 - 0
MediaBrowser.Api/Library/LibraryHelpers.cs

@@ -76,6 +76,11 @@ namespace MediaBrowser.Api.Library
             }
             }
 
 
             if (!string.Equals(currentPath, newPath, StringComparison.OrdinalIgnoreCase) && Directory.Exists(newPath))
             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
                 //Create an unique name
                 var temporaryName = Guid.NewGuid().ToString();
                 var temporaryName = Guid.NewGuid().ToString();
@@ -83,6 +88,7 @@ namespace MediaBrowser.Api.Library
                 Directory.Move(currentPath,temporaryPath);
                 Directory.Move(currentPath,temporaryPath);
                 currentPath = temporaryPath;
                 currentPath = temporaryPath;
             }
             }
+
             Directory.Move(currentPath, newPath);
             Directory.Move(currentPath, newPath);
         }
         }