mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
IOUtils Changes
- added new NormalizeFolder method to format the path parameter, so that it is formed correctly. If the path is a local root path (eg. d:) then it must end with \\. If the path is not a root path, or is a Unc path, then any ending \\ must be removed. This fix was due to an issue with the previous code, as it kept appending a \ to the end when the path was a Unc path.
This commit is contained in:
parent
14cff018cd
commit
bbaad6099f
9 changed files with 210 additions and 222 deletions
|
|
@ -56,38 +56,22 @@ namespace ServerManagerTool
|
|||
|
||||
if (!string.IsNullOrWhiteSpace(Config.Default.DataPath))
|
||||
{
|
||||
var root = Path.GetPathRoot(Config.Default.DataPath);
|
||||
if (!root.EndsWith("\\"))
|
||||
{
|
||||
Config.Default.DataPath = Config.Default.DataPath.Replace(root, root + "\\");
|
||||
}
|
||||
Config.Default.DataPath = IOUtils.NormalizeFolder(Config.Default.DataPath);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Config.Default.ConfigPath))
|
||||
{
|
||||
var root = Path.GetPathRoot(Config.Default.ConfigPath);
|
||||
if (!root.EndsWith("\\"))
|
||||
{
|
||||
Config.Default.ConfigPath = Config.Default.ConfigPath.Replace(root, root + "\\");
|
||||
}
|
||||
Config.Default.ConfigPath = IOUtils.NormalizeFolder(Config.Default.ConfigPath);
|
||||
}
|
||||
|
||||
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 + "\\");
|
||||
}
|
||||
Config.Default.BackupPath = IOUtils.NormalizeFolder(Config.Default.BackupPath);
|
||||
}
|
||||
|
||||
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 + "\\");
|
||||
}
|
||||
Config.Default.AutoUpdate_CacheDir = IOUtils.NormalizeFolder(Config.Default.AutoUpdate_CacheDir);
|
||||
}
|
||||
|
||||
App.Instance = this;
|
||||
|
|
|
|||
|
|
@ -209,69 +209,60 @@ namespace ServerManagerTool
|
|||
dialog.InitialDirectory = Config.Default.DataPath;
|
||||
var result = dialog.ShowDialog(Window.GetWindow(this));
|
||||
|
||||
if (result == CommonFileDialogResult.Ok)
|
||||
if (result != CommonFileDialogResult.Ok)
|
||||
return;
|
||||
|
||||
if (string.Equals(dialog.FileName, Config.Default.DataPath, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.Equals(dialog.FileName, Config.Default.DataPath))
|
||||
var newDataDirectory = IOUtils.NormalizeFolder(dialog.FileName);
|
||||
|
||||
// Set up the destination directories
|
||||
string newConfigDirectory = Path.Combine(newDataDirectory, Config.Default.ProfilesRelativePath);
|
||||
string oldSteamDirectory = Path.Combine(Config.Default.DataPath, CommonConfig.Default.SteamCmdRelativePath);
|
||||
string newSteamDirectory = Path.Combine(newDataDirectory, CommonConfig.Default.SteamCmdRelativePath);
|
||||
|
||||
Directory.CreateDirectory(newConfigDirectory);
|
||||
Directory.CreateDirectory(newSteamDirectory);
|
||||
|
||||
// Copy the Profiles
|
||||
foreach (var file in Directory.EnumerateFiles(Config.Default.ConfigPath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
try
|
||||
string sourceWithoutRoot = file.Substring(Config.Default.ConfigPath.Length + 1);
|
||||
string destination = Path.Combine(newConfigDirectory, sourceWithoutRoot);
|
||||
if (!File.Exists(destination))
|
||||
{
|
||||
var newDataDirectory = dialog.FileName;
|
||||
if (!string.IsNullOrWhiteSpace(newDataDirectory))
|
||||
{
|
||||
var root = Path.GetPathRoot(newDataDirectory);
|
||||
if (!root.EndsWith("\\"))
|
||||
{
|
||||
newDataDirectory = newDataDirectory.Replace(root, root + "\\");
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the destination directories
|
||||
string newConfigDirectory = Path.Combine(newDataDirectory, Config.Default.ProfilesRelativePath);
|
||||
string oldSteamDirectory = Path.Combine(Config.Default.DataPath, CommonConfig.Default.SteamCmdRelativePath);
|
||||
string newSteamDirectory = Path.Combine(newDataDirectory, CommonConfig.Default.SteamCmdRelativePath);
|
||||
|
||||
Directory.CreateDirectory(newConfigDirectory);
|
||||
Directory.CreateDirectory(newSteamDirectory);
|
||||
|
||||
// Copy the Profiles
|
||||
foreach (var file in Directory.EnumerateFiles(Config.Default.ConfigPath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string sourceWithoutRoot = file.Substring(Config.Default.ConfigPath.Length + 1);
|
||||
string destination = Path.Combine(newConfigDirectory, sourceWithoutRoot);
|
||||
if (!File.Exists(destination))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destination));
|
||||
File.Copy(file, destination);
|
||||
}
|
||||
}
|
||||
|
||||
// Copy the SteamCMD files
|
||||
foreach (var file in Directory.EnumerateFiles(oldSteamDirectory, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string sourceWithoutRoot = file.Substring(oldSteamDirectory.Length + 1);
|
||||
string destination = Path.Combine(newSteamDirectory, sourceWithoutRoot);
|
||||
if (!File.Exists(destination))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destination));
|
||||
File.Copy(file, destination);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the old directories
|
||||
Directory.Delete(Config.Default.ConfigPath, true);
|
||||
Directory.Delete(oldSteamDirectory, true);
|
||||
|
||||
// Update the config
|
||||
Config.Default.DataPath = newDataDirectory;
|
||||
Config.Default.ConfigPath = newConfigDirectory;
|
||||
App.ReconfigureLogging();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destination));
|
||||
File.Copy(file, destination);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(String.Format(_globalizer.GetResourceString("GlobalSettings_DataDirectoryChange_FailedLabel"), ex.Message), _globalizer.GetResourceString("GlobalSettings_DataDirectoryChange_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Copy the SteamCMD files
|
||||
foreach (var file in Directory.EnumerateFiles(oldSteamDirectory, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
string sourceWithoutRoot = file.Substring(oldSteamDirectory.Length + 1);
|
||||
string destination = Path.Combine(newSteamDirectory, sourceWithoutRoot);
|
||||
if (!File.Exists(destination))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(destination));
|
||||
File.Copy(file, destination);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the old directories
|
||||
Directory.Delete(Config.Default.ConfigPath, true);
|
||||
Directory.Delete(oldSteamDirectory, true);
|
||||
|
||||
// Update the config
|
||||
Config.Default.DataPath = newDataDirectory;
|
||||
Config.Default.ConfigPath = newConfigDirectory;
|
||||
App.ReconfigureLogging();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(String.Format(_globalizer.GetResourceString("GlobalSettings_DataDirectoryChange_FailedLabel"), ex.Message), _globalizer.GetResourceString("GlobalSettings_DataDirectoryChange_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -299,22 +290,13 @@ namespace ServerManagerTool
|
|||
dialog.InitialDirectory = Config.Default.BackupPath;
|
||||
var result = dialog.ShowDialog(Window.GetWindow(this));
|
||||
|
||||
if (result == CommonFileDialogResult.Ok)
|
||||
{
|
||||
if (!string.Equals(dialog.FileName, Config.Default.BackupPath))
|
||||
{
|
||||
Config.Default.BackupPath = dialog.FileName;
|
||||
if (result != CommonFileDialogResult.Ok)
|
||||
return;
|
||||
|
||||
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.Equals(dialog.FileName, Config.Default.BackupPath, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
Config.Default.BackupPath = IOUtils.NormalizeFolder(dialog.FileName);
|
||||
}
|
||||
|
||||
private void ClearBackupDir_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -330,22 +312,13 @@ namespace ServerManagerTool
|
|||
dialog.InitialDirectory = Config.Default.DataPath;
|
||||
var result = dialog.ShowDialog(Window.GetWindow(this));
|
||||
|
||||
if (result == CommonFileDialogResult.Ok)
|
||||
{
|
||||
if (!string.Equals(dialog.FileName, Config.Default.AutoUpdate_CacheDir))
|
||||
{
|
||||
Config.Default.AutoUpdate_CacheDir = dialog.FileName;
|
||||
if (result != CommonFileDialogResult.Ok)
|
||||
return;
|
||||
|
||||
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 + "\\");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (string.Equals(dialog.FileName, Config.Default.AutoUpdate_CacheDir, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
Config.Default.AutoUpdate_CacheDir = IOUtils.NormalizeFolder(dialog.FileName);
|
||||
}
|
||||
|
||||
private void SteamAPIKeyHelp_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
<entry>
|
||||
<id>urn:uuid:AD8ABBB5-093A-4FDB-B473-FCED2DB46781</id>
|
||||
<title>1.1.69 (1.1.69.6)</title>
|
||||
<summary>1.1.69.6</summary>
|
||||
<title>1.1.69 (1.1.69.7)</title>
|
||||
<summary>1.1.69.7</summary>
|
||||
<link href="" />
|
||||
<updated>2022-05-08T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
|
|
@ -20,6 +20,7 @@
|
|||
<br/>
|
||||
<ul>
|
||||
<li>Fixed an issue that would not send through the auto process messages via RCON using the correct mode selected in the global settings.</li>
|
||||
<li>Fixed an issue with the path normalization, where it would add extra '\' characters to the end of the path, when the path was a Unc path.</li>
|
||||
<li>World Save Backup - fixed the backup of the files.</li>
|
||||
</ul>
|
||||
<u style="font-size: .9em;">CHANGE</u>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,29 @@
|
|||
<link href="http://servermanagers.freeforums.net/" />
|
||||
<updated>2022-05-08T00:00:00Z</updated>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:3DDB3838-5020-4CA3-A054-423479FFB667</id>
|
||||
<title>1.1.69 (1.1.69.7)</title>
|
||||
<summary>1.1.69.7</summary>
|
||||
<link href="" />
|
||||
<updated>2022-05-08T00:00:00Z</updated>
|
||||
<content type="xhtml">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml" style="font-family: Arial, Verdana, Helvetica, Sans-Serif;font-size: .8em;">
|
||||
<p>
|
||||
<u style="font-size: .9em;">BUGFIX</u>
|
||||
<br/>
|
||||
<ul>
|
||||
<li>Fixed an issue with the path normalization, where it would add extra '\' characters to the end of the path, when the path was a Unc path.</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</content>
|
||||
<author>
|
||||
<name>bletch</name>
|
||||
<email>bletch1971@hotmail.com</email>
|
||||
</author>
|
||||
</entry>
|
||||
|
||||
<entry>
|
||||
<id>urn:uuid:72CA1005-0061-41A3-9883-F826B8F9F27F</id>
|
||||
<title>1.1.69 (1.1.69.6)</title>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue