mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-07 03:22:37 +01:00
Duplicated root folders are now blocked.
This commit is contained in:
parent
3cb61e4c34
commit
d967d4198c
@ -92,7 +92,6 @@ public void should_be_able_to_remove_root_dir()
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void None_existing_folder_returns_empty_list()
|
||||
{
|
||||
@ -123,5 +122,16 @@ public void invalid_folder_path_throws_on_add(string path)
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void adding_duplicated_root_folder_should_throw()
|
||||
{
|
||||
WithRealDb();
|
||||
|
||||
//Act
|
||||
var rootDirProvider = Mocker.Resolve<RootDirProvider>();
|
||||
rootDirProvider.Add(new RootDir { Path = @"C:\TV" });
|
||||
Assert.Throws<InvalidOperationException>(() => rootDirProvider.Add(new RootDir { Path = @"C:\TV" }));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -34,7 +34,15 @@ public virtual List<RootDir> GetAll()
|
||||
|
||||
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 @@ public virtual void Remove(int rootDirId)
|
||||
_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");
|
||||
|
@ -93,6 +93,7 @@ public virtual bool SendTestEmail(string server, int port, bool ssl, string user
|
||||
return Send(email, _configProvider.SmtpServer, _configProvider.SmtpPort, _configProvider.SmtpUseSsl, credentials);
|
||||
}
|
||||
|
||||
//TODO: make this throw instead of return false.
|
||||
public virtual bool Send(MailMessage email, string server, int port, bool ssl, NetworkCredential credentials)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user