mirror of https://github.com/Radarr/Radarr
Duplicated root folders are now blocked.
This commit is contained in:
parent
3cb61e4c34
commit
d967d4198c
|
@ -92,7 +92,6 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void None_existing_folder_returns_empty_list()
|
public void None_existing_folder_returns_empty_list()
|
||||||
{
|
{
|
||||||
|
@ -123,5 +122,16 @@ namespace NzbDrone.Core.Test.ProviderTests
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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 @@ namespace NzbDrone.Core.Providers
|
||||||
|
|
||||||
public virtual void Add(RootDir rootDir)
|
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);
|
_database.Insert(rootDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,19 +51,6 @@ namespace NzbDrone.Core.Providers
|
||||||
_database.Delete<RootDir>(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)
|
public List<String> GetUnmappedFolders(string path)
|
||||||
{
|
{
|
||||||
Logger.Debug("Generating list of unmapped folders");
|
Logger.Debug("Generating list of unmapped folders");
|
||||||
|
|
|
@ -93,6 +93,7 @@ namespace NzbDrone.Core.Providers
|
||||||
return Send(email, _configProvider.SmtpServer, _configProvider.SmtpPort, _configProvider.SmtpUseSsl, credentials);
|
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)
|
public virtual bool Send(MailMessage email, string server, int port, bool ssl, NetworkCredential credentials)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
Loading…
Reference in New Issue