From ad89618f58f7e6972949bc1fde909aa28acbfcae Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 10 Jun 2011 14:55:58 -0700 Subject: [PATCH] Directory controller will now swallow errors that would otherwise return invalid data to the client (forcing an annoying alert to the client), no results are returned when this happens. --- .../Controllers/DirectoryController.cs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/NzbDrone.Web/Controllers/DirectoryController.cs b/NzbDrone.Web/Controllers/DirectoryController.cs index 013bc066c..c756de335 100644 --- a/NzbDrone.Web/Controllers/DirectoryController.cs +++ b/NzbDrone.Web/Controllers/DirectoryController.cs @@ -16,11 +16,6 @@ namespace NzbDrone.Web.Controllers _diskProvider = diskProvider; } - public ActionResult Test() - { - return Content("Testing..."); - } - [HttpPost] public ActionResult _autoCompletePath(string text, int? filterMode) { @@ -35,22 +30,29 @@ namespace NzbDrone.Web.Controllers public SelectList GetDirectories(string text) { - //Windows (Including UNC) - var windowsSep = text.LastIndexOf('\\'); - - if (windowsSep > -1) + try { - var dirs = _diskProvider.GetDirectories(text.Substring(0, windowsSep + 1)); - return new SelectList(dirs, dirs.FirstOrDefault()); + //Windows (Including UNC) + var windowsSep = text.LastIndexOf('\\'); + + if (windowsSep > -1) + { + var dirs = _diskProvider.GetDirectories(text.Substring(0, windowsSep + 1)); + return new SelectList(dirs, dirs.FirstOrDefault()); + } + + //Unix + var index = text.LastIndexOf('/'); + + if (index > -1) + { + var dirs = _diskProvider.GetDirectories(text.Substring(0, index + 1)); + return new SelectList(dirs, dirs.FirstOrDefault()); + } } - - //Unix - var index = text.LastIndexOf('/'); - - if (index > -1) + catch(Exception ex) { - var dirs = _diskProvider.GetDirectories(text.Substring(0, index + 1)); - return new SelectList(dirs, dirs.FirstOrDefault()); + //Swallow the exceptions so proper JSON is returned to the client (Empty results) } return new SelectList(new List());