aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Library/LibraryHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Library/LibraryHelpers.cs')
-rw-r--r--MediaBrowser.Api/Library/LibraryHelpers.cs70
1 files changed, 0 insertions, 70 deletions
diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs
index e40cb7dd4..3836a0860 100644
--- a/MediaBrowser.Api/Library/LibraryHelpers.cs
+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs
@@ -68,8 +68,6 @@ namespace MediaBrowser.Api.Library
var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
- ValidateNewMediaPath(fileSystem, rootFolderPath, path);
-
var shortcutFilename = Path.GetFileNameWithoutExtension(path);
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
@@ -82,73 +80,5 @@ namespace MediaBrowser.Api.Library
fileSystem.CreateShortcut(lnk, path);
}
-
- /// <summary>
- /// Validates that a new media path can be added
- /// </summary>
- /// <param name="fileSystem">The file system.</param>
- /// <param name="currentViewRootFolderPath">The current view root folder path.</param>
- /// <param name="mediaPath">The media path.</param>
- /// <exception cref="System.ArgumentException">
- /// </exception>
- private static void ValidateNewMediaPath(IFileSystem fileSystem, string currentViewRootFolderPath, string mediaPath)
- {
- var pathsInCurrentVIew = Directory.EnumerateFiles(currentViewRootFolderPath, ShortcutFileSearch, SearchOption.AllDirectories)
- .Select(fileSystem.ResolveShortcut)
- .ToList();
-
- // Don't allow duplicate sub-paths within the same user library, or it will result in duplicate items
- // See comments in IsNewPathValid
- var duplicate = pathsInCurrentVIew
- .FirstOrDefault(p => !IsNewPathValid(fileSystem, mediaPath, p));
-
- if (!string.IsNullOrEmpty(duplicate))
- {
- throw new ArgumentException(string.Format("The path cannot be added to the library because {0} already exists.", duplicate));
- }
-
- // Make sure the current root folder doesn't already have a shortcut to the same path
- duplicate = pathsInCurrentVIew
- .FirstOrDefault(p => string.Equals(mediaPath, p, StringComparison.OrdinalIgnoreCase));
-
- if (!string.IsNullOrEmpty(duplicate))
- {
- throw new ArgumentException(string.Format("The path {0} already exists in the library", mediaPath));
- }
- }
-
- /// <summary>
- /// Validates that a new path can be added based on an existing path
- /// </summary>
- /// <param name="fileSystem">The file system.</param>
- /// <param name="newPath">The new path.</param>
- /// <param name="existingPath">The existing path.</param>
- /// <returns><c>true</c> if [is new path valid] [the specified new path]; otherwise, <c>false</c>.</returns>
- private static bool IsNewPathValid(IFileSystem fileSystem, string newPath, string existingPath)
- {
- // Example: D:\Movies is the existing path
- // D:\ cannot be added
- // Neither can D:\Movies\Kids
- // A D:\Movies duplicate is ok here since that will be caught later
-
- if (string.Equals(newPath, existingPath, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
-
- // If enforceSubPathRestriction is true, validate the D:\Movies\Kids scenario
- if (fileSystem.ContainsSubPath(existingPath, newPath))
- {
- return false;
- }
-
- // Validate the D:\ scenario
- if (fileSystem.ContainsSubPath(newPath, existingPath))
- {
- return false;
- }
-
- return true;
- }
}
}