mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
Duplicated root folders are now blocked.
This commit is contained in:
parent
3cb61e4c34
commit
d967d4198c
3 changed files with 21 additions and 15 deletions
|
@ -34,7 +34,15 @@ namespace NzbDrone.Core.Providers
|
|||
|
||||
public virtual void Add(RootDir rootDir)
|
||||
{
|
||||
ValidatePath(rootDir);
|
||||
if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path))
|
||||
throw new ArgumentException("Invalid path");
|
||||
|
||||
if (!_diskProvider.FolderExists(rootDir.Path))
|
||||
throw new DirectoryNotFoundException("Can't add root directory that doesn't exist.");
|
||||
|
||||
if (GetAll().Exists(r => DiskProvider.PathEquals(r.Path, rootDir.Path)))
|
||||
throw new InvalidOperationException("Root directory already exist.");
|
||||
|
||||
_database.Insert(rootDir);
|
||||
}
|
||||
|
||||
|
@ -43,19 +51,6 @@ namespace NzbDrone.Core.Providers
|
|||
_database.Delete<RootDir>(rootDirId);
|
||||
}
|
||||
|
||||
private void ValidatePath(RootDir rootDir)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(rootDir.Path) || !Path.IsPathRooted(rootDir.Path))
|
||||
{
|
||||
throw new ArgumentException("Invalid path");
|
||||
}
|
||||
|
||||
if (!_diskProvider.FolderExists(rootDir.Path))
|
||||
{
|
||||
throw new DirectoryNotFoundException("Can't add root directory that doesn't exist.");
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> GetUnmappedFolders(string path)
|
||||
{
|
||||
Logger.Debug("Generating list of unmapped folders");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue