You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/NzbDrone.Api/Directories/DirectoryModule.cs

37 lines
1013 B

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
12 years ago
using NzbDrone.Api.Extensions;
using NzbDrone.Common;
namespace NzbDrone.Api.Directories
{
public class DirectoryModule : NzbDroneApiModule
{
private readonly IDirectoryLookupService _directoryLookupService;
public DirectoryModule(IDirectoryLookupService directoryLookupService)
: base("/directories")
{
_directoryLookupService = directoryLookupService;
Get["/"] = x => GetDirectories();
}
private Response GetDirectories()
{
if (!Request.Query.query.HasValue)
return new List<string>().AsResponse();
string query = Request.Query.query.Value;
var dirs = _directoryLookupService.LookupSubDirectories(query);
if (dirs == null)
throw new Exception("A valid path was not provided");
return dirs.AsResponse();
}
}
}