Implement server backhole downloading

This commit is contained in:
KZ
2015-08-07 22:40:45 +01:00
parent 6d0aa05761
commit 6ea759aeab
15 changed files with 284 additions and 50 deletions

View File

@@ -286,6 +286,7 @@ namespace Jackett.Controllers
cfg["port"] = serverService.Config.Port;
cfg["external"] = serverService.Config.AllowExternal;
cfg["api_key"] = serverService.Config.APIKey;
cfg["blackholedir"] = serverService.Config.BlackholeDir;
cfg["password"] = string.IsNullOrEmpty(serverService.Config.AdminPassword )? string.Empty:serverService.Config.AdminPassword.Substring(0,10);
jsonReply["config"] = cfg;
@@ -300,7 +301,7 @@ namespace Jackett.Controllers
return Json(jsonReply);
}
[Route("set_port")]
[Route("set_config")]
[HttpPost]
public async Task<IHttpActionResult> SetConfig()
{
@@ -312,6 +313,7 @@ namespace Jackett.Controllers
var postData = await ReadPostDataJson();
int port = (int)postData["port"];
bool external = (bool)postData["external"];
string saveDir = (string)postData["blackholedir"];
if (port != Engine.Server.Config.Port || external != Engine.Server.Config.AllowExternal)
{
@@ -361,6 +363,21 @@ namespace Jackett.Controllers
})).Start();
}
if(saveDir != Engine.Server.Config.BlackholeDir)
{
if (!string.IsNullOrEmpty(saveDir))
{
if (!Directory.Exists(saveDir))
{
throw new Exception("Blackhole directory does not exist");
}
}
Engine.Server.Config.BlackholeDir = saveDir;
Engine.Server.SaveConfig();
}
jsonReply["result"] = "success";
jsonReply["port"] = port;
jsonReply["external"] = external;