From b6deb38caec13a4b90a8523996e6141101b1ede1 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 26 Nov 2021 20:08:04 +0000 Subject: [PATCH] --- .vscode/launch.json | 6 +++--- server/AyaNova/Program.cs | 18 +++++++++++------- server/AyaNova/Startup.cs | 3 +-- server/AyaNova/util/FileUtil.cs | 23 +++++++++++------------ 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 3f88bf8e..7df8dbfe 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,9 +52,9 @@ // "AYANOVA_USE_URLS": "http://*:7575;", // //"AYANOVA_REPORT_RENDERING_TIMEOUT": "20000", // //"AYANOVA_REPORT_RENDERING_MAX_INSTANCES": "3", - // "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", - // "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", - // "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", + "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", + "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", + "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", // "AYANOVA_SERVER_TEST_MODE": "false", // "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", // "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-8", diff --git a/server/AyaNova/Program.cs b/server/AyaNova/Program.cs index 9c94df36..534503ec 100644 --- a/server/AyaNova/Program.cs +++ b/server/AyaNova/Program.cs @@ -66,16 +66,18 @@ namespace AyaNova return; } + try + { + FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical(); + } + catch (Exception ex) + { + Console.WriteLine($"Unable to locate or create server file folders error was: {ex.Message}"); + return; + } - - // "AYANOVA_FOLDER_USER_FILES":"%programdata\\ayanova\\userfiles", - // "":"%programdata\\ayanova\\backupfiles", - // "AYANOVA_LOG_LEVEL": "Info", - // "AYANOVA_LOG_PATH":"%programdata\\ayanova\\" - //Human readable config output to console for diagnosis in case server wont' start - var AyaNovaConfig = config.AsEnumerable().Where(z => z.Key.StartsWith("AYANOVA") && z.Key != "AYANOVA_JWT_SECRET" && z.Key != "AYANOVA_SET_SUPERUSER_PW").Select(z => z.Key + "=" + z.Value).ToList(); var DiagConfig = string.Join(",", AyaNovaConfig); DiagConfig = DbUtil.PasswordRedactedConnectionString(DiagConfig); @@ -87,6 +89,8 @@ namespace AyaNova + + #region Initialize Logging //NOTE: there is a logging issue that breaks all this with .net 3.1 hostbuilder vs webhostbuilder but webhostbuilder will be deprecated so we need to work around it //the discussion about that is here: https://github.com/aspnet/AspNetCore/issues/9337 diff --git a/server/AyaNova/Startup.cs b/server/AyaNova/Startup.cs index 6629dde3..b45c98de 100644 --- a/server/AyaNova/Startup.cs +++ b/server/AyaNova/Startup.cs @@ -117,8 +117,7 @@ namespace AyaNova - _newLog.LogDebug("Ensuring user and backup folders exist and are separate locations..."); - FileUtil.EnsureUserAndUtilityFoldersExistAndAreNotIdentical(_hostingEnvironment.ContentRootPath); + //TODO: ENsure report files here diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs index ad29d789..c2089138 100644 --- a/server/AyaNova/util/FileUtil.cs +++ b/server/AyaNova/util/FileUtil.cs @@ -25,25 +25,24 @@ namespace AyaNova.Util /// Throws an exception of they are found to be identical preventing startup /// The reason for this is to prevent a future erase database operation (which erases all attachment files) /// from erasing backups which might prevent recovery in case someone accidentally erases their database - /// - /// + /// /// - internal static void EnsureUserAndUtilityFoldersExistAndAreNotIdentical(string contentRootPath) + internal static void EnsureUserAndUtilityFoldersExistAndAreNotIdentical() { - //UserFiles - if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)) - ServerBootConfig.AYANOVA_FOLDER_USER_FILES = Path.Combine(contentRootPath, "userfiles"); + // //UserFiles + // if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)) + // ServerBootConfig.AYANOVA_FOLDER_USER_FILES = Path.Combine(contentRootPath, "userfiles"); - //BackupFiles - if (ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES == null) - ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES = Path.Combine(contentRootPath, "backupfiles"); + // //BackupFiles + // if (ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES == null) + // ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES = Path.Combine(contentRootPath, "backupfiles"); - //Temporary system files (reports etc) - if (ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES == null) - ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = Path.Combine(contentRootPath, "tempfiles"); + // //Temporary system files (reports etc) + // if (ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES == null) + // ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = Path.Combine(contentRootPath, "tempfiles");