1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-26 01:38:24 +00:00

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.

This commit is contained in:
Mark McDowall 2011-06-10 14:55:58 -07:00
parent 03c6dea53f
commit ad89618f58

View file

@ -16,11 +16,6 @@ public DirectoryController(DiskProvider diskProvider)
_diskProvider = diskProvider;
}
public ActionResult Test()
{
return Content("Testing...");
}
[HttpPost]
public ActionResult _autoCompletePath(string text, int? filterMode)
{
@ -35,22 +30,29 @@ public ActionResult _autoCompletePath(string text, int? filterMode)
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<string>());