mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:16:30 +00:00
rework autoupdate to script only
zoom fix
This commit is contained in:
+16
-27
@@ -54,11 +54,12 @@ public partial class App
|
||||
rollingInterval: RollingInterval.Day)
|
||||
.CreateLogger();
|
||||
|
||||
Parser.Default.ParseArguments<ApiCredentials>(e.Args)
|
||||
.WithParsed(Start)
|
||||
Parser.Default.ParseArguments<ApiCredentials, ApiCredentialsEncrypted>(e.Args)
|
||||
.WithParsed<ApiCredentials>(Start)
|
||||
.WithParsed<ApiCredentialsEncrypted>(StartEncrypted)
|
||||
.WithNotParsed(ErrorHandling);
|
||||
}
|
||||
|
||||
|
||||
private void ErrorHandling(IEnumerable<Error> obj)
|
||||
{
|
||||
Log.Fatal($"Error happened: {string.Join(",", obj.Select(x =>
|
||||
@@ -70,30 +71,11 @@ public partial class App
|
||||
Current.Shutdown();
|
||||
}
|
||||
|
||||
private Stream GetSystemConfig(LoaderClient loaderClient, string apiDir)
|
||||
private Stream GetConfig(LoaderClient loaderClient, string filename, string? apiDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
return loaderClient.LoadFile("config.system.json", apiDir);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Logger.Error(e, e.Message);
|
||||
return new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new
|
||||
{
|
||||
AnnotationConfig = Constants.DefaultAnnotationConfig,
|
||||
AIRecognitionConfig = Constants.DefaultAIRecognitionConfig,
|
||||
GpsDeniedConfig = Constants.DefaultGpsDeniedConfig,
|
||||
ThumbnailConfig = Constants.DefaultThumbnailConfig,
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
private Stream GetSecuredConfig(LoaderClient loaderClient, string apiDir)
|
||||
{
|
||||
try
|
||||
{
|
||||
return loaderClient.LoadFile("config.secured.json", apiDir);
|
||||
return loaderClient.LoadFile(filename, apiDir ?? "");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -102,6 +84,13 @@ public partial class App
|
||||
}
|
||||
}
|
||||
|
||||
private void StartEncrypted(ApiCredentialsEncrypted credsEncrypted)
|
||||
{
|
||||
Log.Logger.Information(credsEncrypted.Creds);
|
||||
Start(Security.Decrypt<ApiCredentials>(credsEncrypted.Creds));
|
||||
}
|
||||
|
||||
|
||||
private void Start(ApiCredentials credentials)
|
||||
{
|
||||
try
|
||||
@@ -109,8 +98,8 @@ public partial class App
|
||||
new ConfigUpdater().CheckConfig();
|
||||
var initConfig = Constants.ReadInitConfig(Log.Logger);
|
||||
var apiDir = initConfig.DirectoriesConfig.ApiResourcesDirectory;
|
||||
|
||||
_loaderClient = new LoaderClient(initConfig.LoaderClientConfig, Log.Logger, _mainCTokenSource.Token);
|
||||
|
||||
_loaderClient.StartClient();
|
||||
_loaderClient.Connect();
|
||||
_loaderClient.Login(credentials);
|
||||
@@ -121,8 +110,8 @@ public partial class App
|
||||
.ConfigureAppConfiguration((_, config) => config
|
||||
.AddCommandLine(Environment.GetCommandLineArgs())
|
||||
.AddJsonFile(Constants.CONFIG_PATH, optional: true, reloadOnChange: true)
|
||||
.AddJsonStream(GetSystemConfig(_loaderClient, apiDir))
|
||||
.AddJsonStream(GetSecuredConfig(_loaderClient, apiDir)))
|
||||
.AddJsonStream(GetConfig(_loaderClient, "config.system.json", apiDir))
|
||||
.AddJsonStream(GetConfig(_loaderClient, "config.secured.json", apiDir)))
|
||||
.UseSerilog()
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user