mirror of https://github.com/Jackett/Jackett
Merge branch 'master' into dotnetcore
This commit is contained in:
commit
6be64bbe36
|
@ -94,61 +94,14 @@ namespace Jackett.Common.Plumbing
|
|||
private ServerConfig BuildServerConfig(IComponentContext ctx)
|
||||
{
|
||||
var configService = ctx.Resolve<IConfigurationService>();
|
||||
// Load config
|
||||
var config = configService.GetConfig<ServerConfig>();
|
||||
if (config == null)
|
||||
{
|
||||
config = new ServerConfig(_runtimeSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
//We don't load these out of the config files as it could get confusing to users who accidently save.
|
||||
//In future we could flatten the serverconfig, and use command line parameters to override any configuration.
|
||||
config.RuntimeSettings = _runtimeSettings;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.APIKey))
|
||||
{
|
||||
// Check for legacy key config
|
||||
var apiKeyFile = Path.Combine(configService.GetAppDataFolder(), "api_key.txt");
|
||||
if (File.Exists(apiKeyFile))
|
||||
{
|
||||
config.APIKey = File.ReadAllText(apiKeyFile);
|
||||
}
|
||||
|
||||
// Check for legacy settings
|
||||
|
||||
var path = Path.Combine(configService.GetAppDataFolder(), "config.json"); ;
|
||||
var jsonReply = new JObject();
|
||||
if (File.Exists(path))
|
||||
{
|
||||
jsonReply = JObject.Parse(File.ReadAllText(path));
|
||||
config.Port = (int)jsonReply["port"];
|
||||
config.AllowExternal = (bool)jsonReply["public"];
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.APIKey))
|
||||
config.APIKey = StringUtil.GenerateRandom(32);
|
||||
|
||||
configService.SaveConfig(config);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.InstanceId))
|
||||
{
|
||||
config.InstanceId = StringUtil.GenerateRandom(64);
|
||||
configService.SaveConfig(config);
|
||||
}
|
||||
config.ConfigChanged();
|
||||
return config;
|
||||
return configService.BuildServerConfig(_runtimeSettings);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static bool DetectMonoCompatabilityWithHttpClient()
|
||||
{
|
||||
bool usehttpclient = false;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@ using System.Security.Principal;
|
|||
using Jackett.Common.Models.Config;
|
||||
using Jackett.Common.Services.Interfaces;
|
||||
using Jackett.Common.Utils;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
|
||||
namespace Jackett.Common.Services
|
||||
|
@ -48,8 +49,6 @@ namespace Jackett.Common.Services
|
|||
dir.SetAccessControl(directorySecurity);
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("App config/log directory: " + GetAppDataFolder());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -240,5 +239,56 @@ namespace Jackett.Common.Services
|
|||
{
|
||||
return EnvironmentUtil.JackettVersion;
|
||||
}
|
||||
|
||||
public ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings)
|
||||
{
|
||||
// Load config
|
||||
var config = GetConfig<ServerConfig>();
|
||||
if (config == null)
|
||||
{
|
||||
config = new ServerConfig(runtimeSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
//We don't load these out of the config files as it could get confusing to users who accidently save.
|
||||
//In future we could flatten the serverconfig, and use command line parameters to override any configuration.
|
||||
config.RuntimeSettings = runtimeSettings;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.APIKey))
|
||||
{
|
||||
// Check for legacy key config
|
||||
var apiKeyFile = Path.Combine(GetAppDataFolder(), "api_key.txt");
|
||||
if (File.Exists(apiKeyFile))
|
||||
{
|
||||
config.APIKey = File.ReadAllText(apiKeyFile);
|
||||
}
|
||||
|
||||
// Check for legacy settings
|
||||
|
||||
var path = Path.Combine(GetAppDataFolder(), "config.json"); ;
|
||||
var jsonReply = new JObject();
|
||||
if (File.Exists(path))
|
||||
{
|
||||
jsonReply = JObject.Parse(File.ReadAllText(path));
|
||||
config.Port = (int)jsonReply["port"];
|
||||
config.AllowExternal = (bool)jsonReply["public"];
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.APIKey))
|
||||
config.APIKey = StringUtil.GenerateRandom(32);
|
||||
|
||||
SaveConfig(config);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(config.InstanceId))
|
||||
{
|
||||
config.InstanceId = StringUtil.GenerateRandom(64);
|
||||
SaveConfig(config);
|
||||
}
|
||||
|
||||
config.ConfigChanged();
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using Jackett.Common.Models.Config;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Jackett.Common.Services.Interfaces
|
||||
{
|
||||
|
@ -15,5 +16,6 @@ namespace Jackett.Common.Services.Interfaces
|
|||
List<string> GetCardigannDefinitionsFolders();
|
||||
void CreateOrMigrateSettings();
|
||||
void PerformMigration();
|
||||
ServerConfig BuildServerConfig(RuntimeSettings runtimeSettings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ using Newtonsoft.Json;
|
|||
namespace Jackett.Common.Services
|
||||
{
|
||||
|
||||
class SerializeService : ISerializeService
|
||||
public class SerializeService : ISerializeService
|
||||
{
|
||||
public string Serialise(object obj)
|
||||
{
|
||||
|
|
|
@ -111,6 +111,8 @@ namespace Jackett.Services
|
|||
logger.Error("Error while getting MaxThreads details: " + e);
|
||||
}
|
||||
|
||||
logger.Info("App config/log directory: " + configService.GetAppDataFolder());
|
||||
|
||||
try
|
||||
{
|
||||
var issuefile = "/etc/issue";
|
||||
|
|
Loading…
Reference in New Issue