Added additional validation when setting directories in the global setting, to ensure they are rooted correctly.

This commit is contained in:
Brett Hewitson 2021-12-15 13:08:30 +10:00
parent 7d6859915d
commit 6a46155463
8 changed files with 200 additions and 20 deletions

View file

@ -49,7 +49,45 @@ namespace ServerManagerTool
public App()
{
if (string.IsNullOrWhiteSpace(Config.Default.ASMUniqueKey))
{
Config.Default.ASMUniqueKey = Guid.NewGuid().ToString();
}
if (!string.IsNullOrWhiteSpace(Config.Default.DataDir))
{
var root = Path.GetPathRoot(Config.Default.DataDir);
if (!root.EndsWith("\\"))
{
Config.Default.DataDir = Config.Default.DataDir.Replace(root, root + "\\");
}
}
if (!string.IsNullOrWhiteSpace(Config.Default.ConfigDirectory))
{
var root = Path.GetPathRoot(Config.Default.ConfigDirectory);
if (!root.EndsWith("\\"))
{
Config.Default.ConfigDirectory = Config.Default.ConfigDirectory.Replace(root, root + "\\");
}
}
if (!string.IsNullOrWhiteSpace(Config.Default.BackupPath))
{
var root = Path.GetPathRoot(Config.Default.BackupPath);
if (!root.EndsWith("\\"))
{
Config.Default.BackupPath = Config.Default.BackupPath.Replace(root, root + "\\");
}
}
if (!string.IsNullOrWhiteSpace(Config.Default.AutoUpdate_CacheDir))
{
var root = Path.GetPathRoot(Config.Default.AutoUpdate_CacheDir);
if (!root.EndsWith("\\"))
{
Config.Default.AutoUpdate_CacheDir = Config.Default.AutoUpdate_CacheDir.Replace(root, root + "\\");
}
}
App.Instance = this;
ApplicationStarted = false;