Updated IndexerSettingsModel with better descriptions.

Enable checkbox for Indexer is now labeled as such.
Removed jscript load for deleted script.
A user will now be unable to add a rootDir if the SabDropDir value is the same (ignoring case).
A user will also be unable to set their SabDropDir to the same value as an exiting RootDir (Ignoring case).
The last two changes prevent users from possibly causing all TV shows to be deleted.
This commit is contained in:
Mark McDowall 2011-09-22 17:18:41 -07:00
commit 95b4250d5d
5 changed files with 21 additions and 10 deletions

View file

@ -153,6 +153,10 @@ namespace NzbDrone.Web.Controllers
if (String.IsNullOrWhiteSpace(path))
return new JsonResult { Data = "failed" };
//Don't let a user add a rootDir that is the same as their SABnzbd TV Directory
if (path.Equals(_configProvider.SabDropDirectory, StringComparison.InvariantCultureIgnoreCase))
return new JsonResult { Data = "failed" };
try
{
_rootFolderProvider.Add(new RootDir { Path = path });

View file

@ -28,14 +28,16 @@ namespace NzbDrone.Web.Controllers
private readonly SeriesProvider _seriesProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
private readonly QualityTypeProvider _qualityTypeProvider;
private readonly RootDirProvider _rootDirProvider;
public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, AutoConfigureProvider autoConfigureProvider,
SeriesProvider seriesProvider, ExternalNotificationProvider externalNotificationProvider,
QualityTypeProvider qualityTypeProvider)
QualityTypeProvider qualityTypeProvider, RootDirProvider rootDirProvider)
{
_externalNotificationProvider = externalNotificationProvider;
_qualityTypeProvider = qualityTypeProvider;
_rootDirProvider = rootDirProvider;
_configProvider = configProvider;
_indexerProvider = indexerProvider;
_qualityProvider = qualityProvider;
@ -315,6 +317,12 @@ namespace NzbDrone.Web.Controllers
{
if (ModelState.IsValid)
{
//Check to see if the TV Directory matches any RootDirs (Ignoring Case), if it does, return an error to the user
//This prevents a user from finding a way to delete their entire TV Library
var rootDirs = _rootDirProvider.GetAll();
if (rootDirs.Any(r => r.Path.Equals(data.SabDropDirectory, StringComparison.InvariantCultureIgnoreCase)))
Json(new NotificationResult { Title = "Failed", Text = "Invalid TV Directory", NotificationType = NotificationType.Error });
_configProvider.SabHost = data.SabHost;
_configProvider.SabPort = data.SabPort;
_configProvider.SabApiKey = data.SabApiKey;