diff --git a/.vscode/launch.json b/.vscode/launch.json index 1a9bf86a..5ffb58fe 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,10 +52,10 @@ // "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_USER_FILES":"%ProgramData%\\ayanova\\userfiles", - "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", - "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", + //"AYANOVA_ATTACHMENT_FILES_PATH": "c:\\temp\\RavenTestData\\userfiles", + "AYANOVA_ATTACHMENT_FILES_PATH":"%ProgramData%\\ayanova\\userfiles", + "AYANOVA_BACKUP_FILES_PATH": "c:\\temp\\RavenTestData\\backupfiles", + "AYANOVA_TEMP_FILES_PATH": "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/docs/8.0/ayanova/docs/common-log.md b/docs/8.0/ayanova/docs/common-log.md index 32b41347..e65e9f04 100644 --- a/docs/8.0/ayanova/docs/common-log.md +++ b/docs/8.0/ayanova/docs/common-log.md @@ -21,7 +21,7 @@ Sometimes 3rd party tools may log to the log file and we may need to restrict th ## Log path -By default AyaNova logs to a "logs" folder situated below the folder where AyaNova is started. +By default AyaNova logs to a `logs` folder in the location specified by [AYANOVA_DATA_PATH](ops-config-data-path.md) setting. You can override this and set a custom log location by command line argument or by setting the "AYANOVA_LOG_PATH" environment variable. Example command line log path parameter diff --git a/docs/8.0/ayanova/docs/ops-config-backup-pgdump-path.md b/docs/8.0/ayanova/docs/ops-config-backup-pgdump-path.md index 8b24e532..18d190dd 100644 --- a/docs/8.0/ayanova/docs/ops-config-backup-pgdump-path.md +++ b/docs/8.0/ayanova/docs/ops-config-backup-pgdump-path.md @@ -18,7 +18,7 @@ The value specified should be a string containing a fully qualified file path to Example command line parameter -`dotnet run --AYANOVA_BACKUP_PG_DUMP_PATH="/usr/lib/postgresql/14.1/bin/"` (not real) +`ayanova.exe --AYANOVA_BACKUP_PG_DUMP_PATH="/usr/lib/postgresql/14.1/bin/"` (not real) Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-data-path.md b/docs/8.0/ayanova/docs/ops-config-data-path.md new file mode 100644 index 00000000..382994a2 --- /dev/null +++ b/docs/8.0/ayanova/docs/ops-config-data-path.md @@ -0,0 +1,44 @@ +# DATA PATH SETTING + +This setting controls where AyaNova stores it's data by default and is required to be present unless all other path related configuration settings are specified individually. + +All data path configurations default to a location under the location specified by AYANOVA_DATA_PATH as follows: + +- AYANOVA_BACKUP_FILES_PATH defaults to 'backup' folder inside AYANOVA_DATA_PATH +- AYANOVA_ATTACHMENT_FILES_PATH defaults to 'attachments' folder inside AYANOVA_DATA_PATH +- AYANOVA_TEMP_FILES_PATH defaults to 'temp' folder inside AYANOVA_DATA_PATH +- AYANOVA_LOG_PATH defaults to 'logs' folder inside AYANOVA_DATA_PATH + + +## Override individual locations + +Each of the path related configuration settings can also be specified individually, any that are left out will default to the above settings. + +## Default + +On Windows computers that use the installer, the default location for this setting is set by the installer the 'ProgramData' folder. There is no default for other operating systems or manual installations. + +## Overriding + +AyaNova expects the data path to be provided by an environment variable or command line parameter named + +`AYANOVA_DATA_PATH` + +The value specified should be a string containing a fully qualified file path for the platform, for example: +`c:\ProgramData\ayanova` + +Example command line parameter + +`ayanova.exe --AYANOVA_DATA_PATH="/var/lib/ayanova"` + +Example environment variable + +Windows + +`set "AYANOVA_DATA_PATH=c:\ProgramData\ayanova"` + +Linux / MAC + +`export AYANOVA_DATA_PATH="/var/lib/ayanova"` + +If both a command line parameter and an environment variable are set the command line parameter takes precedence. diff --git a/docs/8.0/ayanova/docs/ops-config-db.md b/docs/8.0/ayanova/docs/ops-config-db.md index 3ea7f82b..cd208f71 100644 --- a/docs/8.0/ayanova/docs/ops-config-db.md +++ b/docs/8.0/ayanova/docs/ops-config-db.md @@ -14,7 +14,7 @@ AyaNova expects the connection string to be provided by an environment variable Example command line parameter: -`dotnet run --AYANOVA_DB_CONNECTION="Server=localhost;Database=MyAyaNovaDB;"` +`ayanova.exe --AYANOVA_DB_CONNECTION="Server=localhost;Database=MyAyaNovaDB;"` Example environment variable: diff --git a/docs/8.0/ayanova/docs/ops-config-default-translation.md b/docs/8.0/ayanova/docs/ops-config-default-translation.md index 1030821b..a7154df6 100644 --- a/docs/8.0/ayanova/docs/ops-config-default-translation.md +++ b/docs/8.0/ayanova/docs/ops-config-default-translation.md @@ -41,7 +41,7 @@ or Example command line parameter -`dotnet run --AYANOVA_DEFAULT_TRANSLATION="ES"` +`ayanova.exe --AYANOVA_DEFAULT_TRANSLATION="ES"` Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-environment-variables.md b/docs/8.0/ayanova/docs/ops-config-environment-variables.md index 0d8355bd..f3703cc0 100644 --- a/docs/8.0/ayanova/docs/ops-config-environment-variables.md +++ b/docs/8.0/ayanova/docs/ops-config-environment-variables.md @@ -10,9 +10,10 @@ These values can all be specified as an environment variable or as a command lin ## FILE STORAGE LOCATIONS -- [AYANOVA_FOLDER_BACKUP_FILES](ops-config-folder-backup-files.md) -- [AYANOVA_FOLDER_USER_FILES](ops-config-folder-user-files.md) -- [AYANOVA_FOLDER_TEMPORARY_SERVER_FILES](ops-config-folder-temporary-files.md) +- [AYANOVA_DATA_PATH](ops-config-data-path.md) +- [AYANOVA_BACKUP_FILES_PATH](ops-config-folder-backup-files.md) +- [AYANOVA_ATTACHMENT_FILES_PATH](ops-config-folder-user-files.md) +- [AYANOVA_TEMP_FILES_PATH](ops-config-folder-temporary-files.md) ## BACKUP UTILITY "pg_dump" PATH - [AYANOVA_BACKUP_PG_DUMP_PATH](ops-config-backup-pgdump-path.md) diff --git a/docs/8.0/ayanova/docs/ops-config-folder-backup-files.md b/docs/8.0/ayanova/docs/ops-config-folder-backup-files.md index 8dfa7933..3c3b8773 100644 --- a/docs/8.0/ayanova/docs/ops-config-folder-backup-files.md +++ b/docs/8.0/ayanova/docs/ops-config-folder-backup-files.md @@ -2,33 +2,33 @@ This setting controls where AyaNova stores backup and restore files used by the backup and restore features built into AyaNova. -Warning: this folder MUST NOT be the same location set for [AYANOVA_FOLDER_USER_FILES](ops-config-folder-user-files.md) or [AYANOVA_FOLDER_TEMPORARY_SERVER_FILES](ops-config-folder-temporary-files.md) or AyaNova will not start. +Warning: this folder MUST NOT be the same location set for [AYANOVA_ATTACHMENT_FILES_PATH](ops-config-folder-user-files.md) or [AYANOVA_TEMP_FILES_PATH](ops-config-folder-temporary-files.md) or AyaNova will not start. ## Default -If no override is specified AyaNova will store backup files in a `backupfiles` folder in the AyaNova root folder where AyaNova is started from. +If no override is specified AyaNova will store backup files in a `backup` folder in the location specified by [AYANOVA_DATA_PATH](ops-config-data-path.md) setting. ## Overriding AyaNova expects the backup files folder path to be provided by an environment variable or command line parameter named -`AYANOVA_FOLDER_BACKUP_FILES` +`AYANOVA_BACKUP_FILES_PATH` The value specified should be a string containing a fully qualified file path for the platform, for example: `c:\data\ayanova\backupfiles` Example command line parameter -`dotnet run --AYANOVA_FOLDER_BACKUP_FILES="/var/lib/ayanova/backupfiles"` +`ayanova.exe --AYANOVA_BACKUP_FILES_PATH="/var/lib/ayanova/backupfiles"` Example environment variable Windows -`set "AYANOVA_FOLDER_BACKUP_FILES=c:\data\ayanova\backupfiles"` +`set "AYANOVA_BACKUP_FILES_PATH=c:\data\ayanova\backupfiles"` Linux / MAC -`export AYANOVA_FOLDER_BACKUP_FILES="/var/lib/ayanova/backupfiles"` +`export AYANOVA_BACKUP_FILES_PATH="/var/lib/ayanova/backupfiles"` If both a command line parameter and an environment variable are set the command line parameter takes precedence. diff --git a/docs/8.0/ayanova/docs/ops-config-folder-temporary-files.md b/docs/8.0/ayanova/docs/ops-config-folder-temporary-files.md index aef7e728..2c04920b 100644 --- a/docs/8.0/ayanova/docs/ops-config-folder-temporary-files.md +++ b/docs/8.0/ayanova/docs/ops-config-folder-temporary-files.md @@ -2,33 +2,33 @@ This setting controls where AyaNova stores files temporarily while servicing requests such as report generation etc. -Warning: this folder MUST NOT be the same location set for [AYANOVA_FOLDER_USER_FILES](ops-config-folder-user-files.md) or [AYANOVA_FOLDER_BACKUP_FILES](ops-config-folder-backup-files.md) or AyaNova will not start. +Warning: this folder MUST NOT be the same location set for [AYANOVA_ATTACHMENT_FILES_PATH](ops-config-folder-user-files.md) or [AYANOVA_BACKUP_FILES_PATH](ops-config-folder-backup-files.md) or AyaNova will not start. ## Default -If no override is specified AyaNova will store temporary files in a `tempfiles` folder in the AyaNova root folder where AyaNova is started from. +If no override is specified AyaNova will store temporary files in a `tempfiles` folder in the location specified by [AYANOVA_DATA_PATH](ops-config-data-path.md) setting. ## Overriding AyaNova expects the temporary files folder path to be provided by an environment variable or command line parameter named -`AYANOVA_FOLDER_TEMPORARY_SERVER_FILES` +`AYANOVA_TEMP_FILES_PATH` The value specified should be a string containing a fully qualified file path for the platform, for example: `c:\data\ayanova\tempfiles` Example command line parameter -`dotnet run --AYANOVA_FOLDER_TEMPORARY_SERVER_FILES="/var/lib/ayanova/tempfiles"` +`ayanova.exe --AYANOVA_TEMP_FILES_PATH="/var/lib/ayanova/tempfiles"` Example environment variable Windows -`set "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES=c:\data\ayanova\tempfiles"` +`set "AYANOVA_TEMP_FILES_PATH=c:\data\ayanova\tempfiles"` Linux / MAC -`export AYANOVA_FOLDER_TEMPORARY_SERVER_FILES="/var/lib/ayanova/tempfiles"` +`export AYANOVA_TEMP_FILES_PATH="/var/lib/ayanova/tempfiles"` If both a command line parameter and an environment variable are set the command line parameter takes precedence. diff --git a/docs/8.0/ayanova/docs/ops-config-folder-user-files.md b/docs/8.0/ayanova/docs/ops-config-folder-user-files.md index 4b91fcba..e7aafed8 100644 --- a/docs/8.0/ayanova/docs/ops-config-folder-user-files.md +++ b/docs/8.0/ayanova/docs/ops-config-folder-user-files.md @@ -3,33 +3,33 @@ This setting controls where AyaNova stores user uploaded files used by features that allow file attachment or uploads. AyaNova stores these files with random names in the folder specified. -Warning: this folder MUST NOT be the same location set for [AYANOVA_FOLDER_BACKUP_FILES](ops-config-folder-backup-files.md) or [AYANOVA_FOLDER_TEMPORARY_SERVER_FILES](ops-config-folder-temporary-files.md) or AyaNova will not start. +Warning: this folder MUST NOT be the same location set for [AYANOVA_BACKUP_FILES_PATH](ops-config-folder-backup-files.md) or [AYANOVA_TEMP_FILES_PATH](ops-config-folder-temporary-files.md) or AyaNova will not start. ## Default -If no override is specified AyaNova will store user files in a `userfiles` folder in the AyaNova root folder where AyaNova is started from. +If no override is specified AyaNova will store user files in a `userfiles` folder in the location specified by [AYANOVA_DATA_PATH](ops-config-data-path.md) setting. ## Overriding AyaNova expects the user files folder path to be provided by an environment variable or command line parameter named -`AYANOVA_FOLDER_USER_FILES` +`AYANOVA_ATTACHMENT_FILES_PATH` The value specified should be a string containing a fully qualified file path for the platform, for example: `c:\data\ayanova\userfiles` Example command line parameter -`dotnet run --AYANOVA_FOLDER_USER_FILES="/var/lib/ayanova/userfiles"` +`ayanova.exe --AYANOVA_ATTACHMENT_FILES_PATH="/var/lib/ayanova/userfiles"` Example environment variable Windows -`set "AYANOVA_FOLDER_USER_FILES=c:\data\ayanova\userfiles"` +`set "AYANOVA_ATTACHMENT_FILES_PATH=c:\data\ayanova\userfiles"` Linux / MAC -`export AYANOVA_FOLDER_USER_FILES="/var/lib/ayanova/userfiles"` +`export AYANOVA_ATTACHMENT_FILES_PATH="/var/lib/ayanova/userfiles"` If both a command line parameter and an environment variable are set the command line parameter takes precedence. diff --git a/docs/8.0/ayanova/docs/ops-config-jwt-secret.md b/docs/8.0/ayanova/docs/ops-config-jwt-secret.md index 2e752b83..af148375 100644 --- a/docs/8.0/ayanova/docs/ops-config-jwt-secret.md +++ b/docs/8.0/ayanova/docs/ops-config-jwt-secret.md @@ -31,7 +31,7 @@ You should use the same precautions as for choosing any other password and ensur Example command line parameter -`dotnet run --AYANOVA_JWT_SECRET="02847This_is_my_secret_key456576"` +`ayanova.exe --AYANOVA_JWT_SECRET="02847This_is_my_secret_key456576"` Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-report-rendering-max-instances.md b/docs/8.0/ayanova/docs/ops-config-report-rendering-max-instances.md index d079ea56..f2048c12 100644 --- a/docs/8.0/ayanova/docs/ops-config-report-rendering-max-instances.md +++ b/docs/8.0/ayanova/docs/ops-config-report-rendering-max-instances.md @@ -40,7 +40,7 @@ The value specified should be a string specifying the value as an integer, for e Example command line parameter -`dotnet run --AYANOVA_REPORT_RENDERING_MAX_INSTANCES="5` +`ayanova.exe --AYANOVA_REPORT_RENDERING_MAX_INSTANCES="5` Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md b/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md index 2a0b7eae..0943d660 100644 --- a/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md +++ b/docs/8.0/ayanova/docs/ops-config-report-rendering-timeout.md @@ -41,7 +41,7 @@ The value specified should be a string specifying the timeout in **milliseconds* Example command line parameter -`dotnet run --AYANOVA_REPORT_RENDERING_TIMEOUT="30000` +`ayanova.exe --AYANOVA_REPORT_RENDERING_TIMEOUT="30000` Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-set-superuser-pw.md b/docs/8.0/ayanova/docs/ops-config-set-superuser-pw.md index a24c9a18..695c05cb 100644 --- a/docs/8.0/ayanova/docs/ops-config-set-superuser-pw.md +++ b/docs/8.0/ayanova/docs/ops-config-set-superuser-pw.md @@ -20,7 +20,7 @@ The value specified should be a string used to temporarily override the super us Example command line parameter -`dotnet run --AYANOVA_SET_SUPERUSER_PW="Th3RainInSpainFallsMainlyOnTh3Pla1n"` +`ayanova.exe --AYANOVA_SET_SUPERUSER_PW="Th3RainInSpainFallsMainlyOnTh3Pla1n"` Example environment variable diff --git a/docs/8.0/ayanova/docs/ops-config-use-urls.md b/docs/8.0/ayanova/docs/ops-config-use-urls.md index 87829e4a..5519e04c 100644 --- a/docs/8.0/ayanova/docs/ops-config-use-urls.md +++ b/docs/8.0/ayanova/docs/ops-config-use-urls.md @@ -21,7 +21,7 @@ The value specified should be a string of one or more semicolon separated values Example command line parameter -`dotnet run --AYANOVA_USE_URLS="http://*:5000"` +`ayanova.exe --AYANOVA_USE_URLS="http://*:5000"` Example environment variable diff --git a/server/AyaNova/Controllers/ServerStateController.cs b/server/AyaNova/Controllers/ServerStateController.cs index e7a2881d..605a4460 100644 --- a/server/AyaNova/Controllers/ServerStateController.cs +++ b/server/AyaNova/Controllers/ServerStateController.cs @@ -184,9 +184,9 @@ namespace AyaNova.Api.Controllers AYANOVA_USE_URLS = ServerBootConfig.AYANOVA_USE_URLS, AYANOVA_DB_CONNECTION = DbUtil.PasswordRedactedConnectionString(ServerBootConfig.AYANOVA_DB_CONNECTION), AYANOVA_REPORT_RENDERING_TIMEOUT = ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT, - AYANOVA_FOLDER_USER_FILES = ServerBootConfig.AYANOVA_FOLDER_USER_FILES, - AYANOVA_FOLDER_BACKUP_FILES = ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, - AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES, + AYANOVA_ATTACHMENT_FILES_PATH = ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, + AYANOVA_BACKUP_FILES_PATH = ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, + AYANOVA_TEMP_FILES_PATH = ServerBootConfig.AYANOVA_TEMP_FILES_PATH, AYANOVA_BACKUP_PG_DUMP_PATH = ServerBootConfig.AYANOVA_BACKUP_PG_DUMP_PATH, AYANOVA_LOG_PATH = ServerBootConfig.AYANOVA_LOG_PATH, AYANOVA_LOG_LEVEL = ServerBootConfig.AYANOVA_LOG_LEVEL, diff --git a/server/AyaNova/Program.cs b/server/AyaNova/Program.cs index 87d09135..1c79d19b 100644 --- a/server/AyaNova/Program.cs +++ b/server/AyaNova/Program.cs @@ -217,22 +217,22 @@ namespace AyaNova long UtilityFilesAvailableSpace = 0; try { - // Console.WriteLine($"##### program:about to call backupfilesdriveavailablespace, config is [{ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES}] ######"); - UtilityFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace; + // Console.WriteLine($"##### program:about to call backupfilesdriveavailablespace, config is [{ServerBootConfig.AYANOVA_BACKUP_FILES_PATH}] ######"); + UtilityFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)).AvailableFreeSpace; } catch (Exception ex) { - logger.Error(ex, $"BOOT::FileUtil::UtilityFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)}]"); + logger.Error(ex, $"BOOT::FileUtil::UtilityFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)}]"); } long AttachmentFilesAvailableSpace = 0; try { - AttachmentFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)).AvailableFreeSpace; + AttachmentFilesAvailableSpace = new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH)).AvailableFreeSpace; } catch (Exception ex) { - logger.Error(ex, $"BOOT::FileUtil::AttachmentFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)}]"); + logger.Error(ex, $"BOOT::FileUtil::AttachmentFilesDriveAvailableSpace error getting available space from [{Path.GetPathRoot(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH)}]"); } diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs index d9b8011f..feda9538 100644 --- a/server/AyaNova/util/FileUtil.cs +++ b/server/AyaNova/util/FileUtil.cs @@ -31,34 +31,34 @@ namespace AyaNova.Util { // //UserFiles - // if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)) - // ServerBootConfig.AYANOVA_FOLDER_USER_FILES = Path.Combine(contentRootPath, "userfiles"); + // if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH)) + // ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH = Path.Combine(contentRootPath, "userfiles"); // //BackupFiles - // if (ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES == null) - // ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES = Path.Combine(contentRootPath, "backupfiles"); + // if (ServerBootConfig.AYANOVA_BACKUP_FILES_PATH == null) + // ServerBootConfig.AYANOVA_BACKUP_FILES_PATH = 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"); + // if (ServerBootConfig.AYANOVA_TEMP_FILES_PATH == null) + // ServerBootConfig.AYANOVA_TEMP_FILES_PATH = Path.Combine(contentRootPath, "tempfiles"); //Prevent using the same folder for both if ( - string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_USER_FILES), Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES), StringComparison.OrdinalIgnoreCase) || - string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_USER_FILES), Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES), StringComparison.OrdinalIgnoreCase) || - string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES), Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES), StringComparison.OrdinalIgnoreCase) + string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH), Path.GetFullPath(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH), StringComparison.OrdinalIgnoreCase) || + string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH), Path.GetFullPath(ServerBootConfig.AYANOVA_TEMP_FILES_PATH), StringComparison.OrdinalIgnoreCase) || + string.Equals(Path.GetFullPath(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH), Path.GetFullPath(ServerBootConfig.AYANOVA_TEMP_FILES_PATH), StringComparison.OrdinalIgnoreCase) ) { - throw new System.NotSupportedException("E1040: The configuration settings AYANOVA_FOLDER_USER_FILES, AYANOVA_FOLDER_BACKUP_FILES and AYANOVA_FOLDER_TEMPORARY_SYSTEM_FILES must all be different locations"); + throw new System.NotSupportedException("E1040: The configuration settings AYANOVA_ATTACHMENT_FILES_PATH, AYANOVA_BACKUP_FILES_PATH and AYANOVA_FOLDER_TEMPORARY_SYSTEM_FILES must all be different locations"); } - EnsurePath(ServerBootConfig.AYANOVA_FOLDER_USER_FILES); - EnsurePath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES); - EnsurePath(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES); + EnsurePath(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH); + EnsurePath(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH); + EnsurePath(ServerBootConfig.AYANOVA_TEMP_FILES_PATH); } //create path if doesn't exist already @@ -90,7 +90,7 @@ namespace AyaNova.Util { get { - return ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES; + return ServerBootConfig.AYANOVA_TEMP_FILES_PATH; } } @@ -151,7 +151,7 @@ namespace AyaNova.Util /// internal static string GetFullPathForBackupFile(string fileName) { - return Path.Combine(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, fileName); + return Path.Combine(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, fileName); } @@ -163,7 +163,7 @@ namespace AyaNova.Util // { // get // { - // return ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES; + // return ServerBootConfig.AYANOVA_BACKUP_FILES_PATH; // } // } @@ -197,7 +197,7 @@ namespace AyaNova.Util BackupStatus statusReport = new BackupStatus(); try { - statusReport.AvailableFreeSpace = GetBytesReadable(new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace); + statusReport.AvailableFreeSpace = GetBytesReadable(new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)).AvailableFreeSpace); } catch (Exception ex) { @@ -206,7 +206,7 @@ namespace AyaNova.Util log.LogError(ex, "FileUtil::BackupStatusReport error getting available space"); } - var backupFiles = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, "*"); + var backupFiles = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, "*"); foreach (string file in backupFiles.OrderByDescending(z => z)) { @@ -246,7 +246,7 @@ namespace AyaNova.Util internal static DateTime MostRecentAutomatedBackupFileDate() { DateTime LastBackup = DateTime.MinValue; - foreach (string file in Directory.EnumerateFiles(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, "db-*.backup")) + foreach (string file in Directory.EnumerateFiles(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, "db-*.backup")) { var ThisFileTime = File.GetCreationTimeUtc(file); if (ThisFileTime > LastBackup) @@ -298,7 +298,7 @@ namespace AyaNova.Util name = Path.GetFileName(name);//ensure no directory shenanigans, only a file name is allowed //remove the file completely - var DeleteFilePath = Path.Combine(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, name); + var DeleteFilePath = Path.Combine(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, name); if (File.Exists(DeleteFilePath)) { //delete the temp file, it's already stored @@ -318,7 +318,7 @@ namespace AyaNova.Util if (keepCount < 1) keepCount = 1; //Database backups - var BackupFileList = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, "db-*.backup"); + var BackupFileList = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, "db-*.backup"); if (BackupFileList.Count() > keepCount) { //sort, skip newest x (keepcount) delete the rest @@ -331,7 +331,7 @@ namespace AyaNova.Util } //Attachment backups - BackupFileList = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES, "at-*.zip"); + BackupFileList = Directory.EnumerateFiles(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH, "at-*.zip"); if (BackupFileList.Count() > keepCount) { //sort, skip newest x (keepcount) delete the rest @@ -347,10 +347,10 @@ namespace AyaNova.Util internal static long BackupFilesDriveAvailableSpace() { - //Console.WriteLine("b fileutil:backupfilesdriveavailablespace, backupfilesfolder:", ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES); - //Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder FULLPATH:", Path.GetFullPath(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)); - // Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder PATHROOT:", Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)); - return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)).AvailableFreeSpace; + //Console.WriteLine("b fileutil:backupfilesdriveavailablespace, backupfilesfolder:", ServerBootConfig.AYANOVA_BACKUP_FILES_PATH); + //Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder FULLPATH:", Path.GetFullPath(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)); + // Console.WriteLine("fileutil:backupfilesdriveavailablespace, backupfilesfolder PATHROOT:", Path.GetPathRoot(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)); + return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)).AvailableFreeSpace; } @@ -402,7 +402,7 @@ namespace AyaNova.Util // { // get // { - // return ServerBootConfig.AYANOVA_FOLDER_USER_FILES; + // return ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH; // } // } @@ -417,7 +417,7 @@ namespace AyaNova.Util { get { - return Path.Combine(ServerBootConfig.AYANOVA_FOLDER_USER_FILES, NewRandomFileName); + return Path.Combine(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, NewRandomFileName); } } @@ -486,7 +486,7 @@ namespace AyaNova.Util /// Path without the file internal static string GetPermanentAttachmentPath(string hash) { - return Path.Combine(ServerBootConfig.AYANOVA_FOLDER_USER_FILES, hash[0].ToString(), hash[1].ToString(), hash[2].ToString()); + return Path.Combine(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, hash[0].ToString(), hash[1].ToString(), hash[2].ToString()); } /// @@ -496,7 +496,7 @@ namespace AyaNova.Util /// internal static string GetPermanentAttachmentFilePath(string hash) { - return Path.Combine(ServerBootConfig.AYANOVA_FOLDER_USER_FILES, hash[0].ToString(), hash[1].ToString(), hash[2].ToString(), hash); + return Path.Combine(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, hash[0].ToString(), hash[1].ToString(), hash[2].ToString(), hash); } @@ -554,7 +554,7 @@ namespace AyaNova.Util /// internal static void EraseEntireContentsOfAttachmentFilesFolder() { - System.IO.DirectoryInfo di = new DirectoryInfo(ServerBootConfig.AYANOVA_FOLDER_USER_FILES); + System.IO.DirectoryInfo di = new DirectoryInfo(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH); foreach (FileInfo file in di.EnumerateFiles()) { file.Delete(); @@ -573,7 +573,7 @@ namespace AyaNova.Util var AttachmentsBackupFile = $"{demandFileNamePrepend}at-{FileUtil.GetSafeDateFileName()}.zip";//presentation issue so don't use UTC for this one AttachmentsBackupFile = GetFullPathForBackupFile(AttachmentsBackupFile); - System.IO.Compression.ZipFile.CreateFromDirectory(ServerBootConfig.AYANOVA_FOLDER_USER_FILES, AttachmentsBackupFile); + System.IO.Compression.ZipFile.CreateFromDirectory(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, AttachmentsBackupFile); } catch (Exception ex) { @@ -587,12 +587,12 @@ namespace AyaNova.Util internal static long AttachmentFilesDriveAvailableSpace() { - return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)).AvailableFreeSpace; + return new System.IO.DriveInfo(Path.GetPathRoot(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH)).AvailableFreeSpace; } internal static IEnumerable GetAllAttachmentFilePaths() { - return Directory.EnumerateFiles(ServerBootConfig.AYANOVA_FOLDER_USER_FILES, "*", SearchOption.AllDirectories); + return Directory.EnumerateFiles(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH, "*", SearchOption.AllDirectories); } @@ -710,7 +710,7 @@ namespace AyaNova.Util /// internal static FolderSizeInfo GetAttachmentFolderSizeInfo() { - return GetDirectorySize(new DirectoryInfo(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)); + return GetDirectorySize(new DirectoryInfo(ServerBootConfig.AYANOVA_ATTACHMENT_FILES_PATH)); } /// @@ -719,7 +719,7 @@ namespace AyaNova.Util /// internal static FolderSizeInfo GetBackupFolderSizeInfo() { - return GetDirectorySize(new DirectoryInfo(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)); + return GetDirectorySize(new DirectoryInfo(ServerBootConfig.AYANOVA_BACKUP_FILES_PATH)); } diff --git a/server/AyaNova/util/ServerBootConfig.cs b/server/AyaNova/util/ServerBootConfig.cs index 7ce8b21b..fd5ef413 100644 --- a/server/AyaNova/util/ServerBootConfig.cs +++ b/server/AyaNova/util/ServerBootConfig.cs @@ -70,9 +70,9 @@ namespace AyaNova.Util internal static bool AYANOVA_PERMANENTLY_ERASE_DATABASE { get; set; } //FILE FOLDERS - internal static string AYANOVA_FOLDER_USER_FILES { get; set; } - internal static string AYANOVA_FOLDER_BACKUP_FILES { get; set; } - internal static string AYANOVA_FOLDER_TEMPORARY_SERVER_FILES { get; set; } + internal static string AYANOVA_ATTACHMENT_FILES_PATH { get; set; } + internal static string AYANOVA_BACKUP_FILES_PATH { get; set; } + internal static string AYANOVA_TEMP_FILES_PATH { get; set; } //BACKUP PG_DUMP PATH (IF NOT IN PATH ALREADY) internal static string AYANOVA_BACKUP_PG_DUMP_PATH { get; set; } @@ -162,6 +162,9 @@ namespace AyaNova.Util AYANOVA_JWT_SECRET = config.GetValue("AYANOVA_JWT_SECRET"); + //backdoor back door password superuser reset + AYANOVA_SET_SUPERUSER_PW = config.GetValue("AYANOVA_SET_SUPERUSER_PW"); + //REPORT RENDERING PROCESS CONTROL int? nTemp = config.GetValue("AYANOVA_REPORT_RENDERING_TIMEOUT"); AYANOVA_REPORT_RENDERING_TIMEOUT = (null == nTemp) ? 30000 : (int)nTemp;//default is 30 seconds @@ -180,79 +183,46 @@ namespace AyaNova.Util //FOLDERS + string DataFolderPath = ActualFullPath(config.GetValue("AYANOVA_DATA_PATH")); + string LogPath = ActualFullPath(config.GetValue("AYANOVA_LOG_PATH")); + string AttachmentFilesPath = ActualFullPath(config.GetValue("AYANOVA_USER_FILES_PATH")); + string BackupFilesPath = ActualFullPath(config.GetValue("AYANOVA_BACKUP_FILES_PATH")); + string TempFilesPath = ActualFullPath(config.GetValue("AYANOVA_TEMP_FILES_PATH")); + AYANOVA_BACKUP_PG_DUMP_PATH = ActualFullPath(config.GetValue("AYANOVA_BACKUP_PG_DUMP_PATH")); - //TODO: Implement system where one single data folder can be specified and AyaNova will use that and subfolders under it automatically - //but also it honours if specific overrides were set for alternative locations - //change "folder" to "path" and update docs and everywhere it's mentioned - //AYANOVA_DATA_PATH <---this is used as "root" for all data paths automatically unless more specific - string AyaPath = string.Empty; + if (string.IsNullOrWhiteSpace(DataFolderPath)) + { + //then they better have paths for *everything* specified + if (string.IsNullOrWhiteSpace(LogPath)) + throw new System.ArgumentNullException("AYANOVA_LOG_PATH configuration setting missing and required"); + if (string.IsNullOrWhiteSpace(AttachmentFilesPath)) + throw new System.ArgumentNullException("AYANOVA_ATTACHMENT_FILES_PATH configuration setting missing and required"); + if (string.IsNullOrWhiteSpace(BackupFilesPath)) + throw new System.ArgumentNullException("AYANOVA_BACKUP_FILES_PATH configuration setting missing and required"); + if (string.IsNullOrWhiteSpace(TempFilesPath)) + throw new System.ArgumentNullException("AYANOVA_TEMP_FILES_PATH configuration setting missing and required"); - //Log folder - AyaPath = config.GetValue("AYANOVA_LOG_PATH"); - if (string.IsNullOrWhiteSpace(AyaPath)) - throw new System.ArgumentNullException("AYANOVA_LOG_PATH configuration setting missing and required"); - AYANOVA_LOG_PATH = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(AYANOVA_LOG_PATH)); - /* - if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_DB_CONNECTION)) - { - Console.WriteLine($"FAIL: AYANOVA_DB_CONNECTION configuration setting missing and required"); - HaveAllCrticalConfigValues = false; - } - - if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_BACKUP_FILES)) - { - Console.WriteLine($"FAIL: AYANOVA_FOLDER_BACKUP_FILES configuration setting missing and required"); - HaveAllCrticalConfigValues = false; - } - - if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_USER_FILES)) - { - Console.WriteLine($"FAIL: AYANOVA_FOLDER_USER_FILES configuration setting missing and required"); - HaveAllCrticalConfigValues = false; - } - - if (string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_FOLDER_TEMPORARY_SERVER_FILES)) - { - Console.WriteLine($"FAIL: AYANOVA_FOLDER_TEMPORARY_SERVER_FILES configuration setting missing and required"); - HaveAllCrticalConfigValues = false; - } - - */ - - // if (string.IsNullOrWhiteSpace(AYANOVA_LOG_PATH)) - // { - // //DEFAULT LOG PATH - // var currentDir = Directory.GetCurrentDirectory(); - // AYANOVA_LOG_PATH = Path.Combine(currentDir, "logs"); - // } - // else - // { - // AYANOVA_LOG_PATH = Path.Combine(AYANOVA_LOG_PATH, "logs"); - // } - - //(note, startup.cs ensures these folders exist via FileUtil because we need IHostingEnvironment) - //UserFiles - AYANOVA_FOLDER_USER_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue("AYANOVA_FOLDER_USER_FILES"))); - - //BackupFiles - AYANOVA_FOLDER_BACKUP_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue("AYANOVA_FOLDER_BACKUP_FILES"))); - - //TemporaryFiles - AYANOVA_FOLDER_TEMPORARY_SERVER_FILES = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue("AYANOVA_FOLDER_TEMPORARY_SERVER_FILES"))); - - //pgdump backup utility path - AYANOVA_BACKUP_PG_DUMP_PATH = Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(config.GetValue("AYANOVA_BACKUP_PG_DUMP_PATH"))); - - //backdoor back door password superuser reset - AYANOVA_SET_SUPERUSER_PW = config.GetValue("AYANOVA_SET_SUPERUSER_PW"); + } + else + { + //set any unspecified paths to the defaults + AYANOVA_LOG_PATH = (string.IsNullOrWhiteSpace(LogPath)) ? Path.Combine(DataFolderPath, "logs") : LogPath; + AYANOVA_ATTACHMENT_FILES_PATH = (string.IsNullOrWhiteSpace(AttachmentFilesPath)) ? Path.Combine(DataFolderPath, "attachments") : AttachmentFilesPath; + AYANOVA_BACKUP_FILES_PATH = (string.IsNullOrWhiteSpace(BackupFilesPath)) ? Path.Combine(DataFolderPath, "backups") : BackupFilesPath; + AYANOVA_TEMP_FILES_PATH = (string.IsNullOrWhiteSpace(TempFilesPath)) ? Path.Combine(DataFolderPath, "temp") : TempFilesPath; + } #endregion server BASICS - - } + internal static string ActualFullPath(string p) + { + if (string.IsNullOrWhiteSpace(p)) + return string.Empty; + return Path.GetFullPath(FileUtil.StringPathDecodeEnvironmentVariables(p)); + } //Fetch first url from list of urls (used by generator) internal static string FirstOfAyaNovaUseUrls