From 95b4250d5dd62b80d7765302c83a276153a1d922 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 22 Sep 2011 17:18:41 -0700 Subject: [PATCH] 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. --- NzbDrone.Web/Controllers/AddSeriesController.cs | 4 ++++ NzbDrone.Web/Controllers/SettingsController.cs | 10 +++++++++- NzbDrone.Web/Models/IndexerSettingsModel.cs | 8 ++++---- NzbDrone.Web/Views/Settings/Indexers.cshtml | 8 ++++---- NzbDrone.Web/Views/Shared/_Layout.cshtml | 1 - 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index b4b6207ee..429de70f7 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -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 }); diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 4056dcac6..b31666f57 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -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; diff --git a/NzbDrone.Web/Models/IndexerSettingsModel.cs b/NzbDrone.Web/Models/IndexerSettingsModel.cs index 1f0e089e8..afee322d2 100644 --- a/NzbDrone.Web/Models/IndexerSettingsModel.cs +++ b/NzbDrone.Web/Models/IndexerSettingsModel.cs @@ -57,19 +57,19 @@ namespace NzbDrone.Web.Models public String NewzbinPassword { get; set; } [DisplayName("NZBs.org")] - [Description("Scan Nzbs.org for new epsiodes")] + [Description("Enable downloading episodes from Nzbs.org")] public bool NzbsOrgEnabled { get; set; } [DisplayName("NZB Matrix")] - [Description("Scan NZB Matrix for new epsiodes")] + [Description("Enable downloading episodes from NZB Matrix")] public bool NzbMatrixEnabled { get; set; } [DisplayName("NZBsRUs")] - [Description("Scan NZBsRus for new epsiodes")] + [Description("Enable downloading episodes from NZBsRus")] public bool NzbsRUsEnabled { get; set; } [DisplayName("Newzbin")] - [Description("Scan Newzbin for new epsiodes")] + [Description("Enable downloading episodes from Newzbin")] public bool NewzbinEnabled { get; set; } } } \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml index b867f7f65..898eca52d 100644 --- a/NzbDrone.Web/Views/Settings/Indexers.cshtml +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -42,7 +42,7 @@ .ImageUrl("~/Content/Images/Indexers/Nzbs.org.png") .Content(@
-