mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 08:07:10 -07:00
Root Dir cleanup
This commit is contained in:
parent
07312780f1
commit
cece6e9bf6
10 changed files with 144 additions and 59 deletions
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
|
||||
|
@ -28,26 +29,28 @@ namespace NzbDrone.Web.Controllers
|
|||
};
|
||||
}
|
||||
|
||||
public SelectList GetDirectories(string text)
|
||||
[HttpGet]
|
||||
public JsonResult GetDirectories(string q)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Windows (Including UNC)
|
||||
var windowsSep = text.LastIndexOf('\\');
|
||||
var windowsSep = q.LastIndexOf('\\');
|
||||
|
||||
if (windowsSep > -1)
|
||||
{
|
||||
var dirs = _diskProvider.GetDirectories(text.Substring(0, windowsSep + 1));
|
||||
return new SelectList(dirs, dirs.FirstOrDefault());
|
||||
var dirs = _diskProvider.GetDirectories(q.Substring(0, windowsSep + 1));
|
||||
return Json(dirs, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
return Json(new string[] { }, JsonRequestBehavior.AllowGet);
|
||||
//Unix
|
||||
var index = text.LastIndexOf('/');
|
||||
var index = q.LastIndexOf('/');
|
||||
|
||||
if (index > -1)
|
||||
{
|
||||
var dirs = _diskProvider.GetDirectories(text.Substring(0, index + 1));
|
||||
return new SelectList(dirs, dirs.FirstOrDefault());
|
||||
var dirs = _diskProvider.GetDirectories(q.Substring(0, index + 1));
|
||||
//return new SelectList(dirs, dirs.FirstOrDefault());
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -55,7 +58,7 @@ namespace NzbDrone.Web.Controllers
|
|||
//Swallow the exceptions so proper JSON is returned to the client (Empty results)
|
||||
}
|
||||
|
||||
return new SelectList(new List<string>());
|
||||
return Json(new string[]{}, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue