Fixed a crashing bug when the server manager closes and is unable to find the backup location to save the config settings.

This commit is contained in:
Brett Hewitson 2021-11-23 16:04:41 +10:00
parent 34582ca91b
commit 9d5dafaed6
7 changed files with 37 additions and 10 deletions

View file

@ -16,6 +16,11 @@
<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 a crashing bug when ASM closes and is unable to find the backup location to save the config settings.</li>
</ul>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>

View file

@ -16,6 +16,11 @@
<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 a crashing bug when ASM closes and is unable to find the backup location to save the config settings.</li>
</ul>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>

View file

@ -218,7 +218,7 @@ namespace ServerManagerTool
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState != WindowState.Minimized)
if (this.WindowState == WindowState.Normal)
{
Config.Default.MainWindow_Height = e.NewSize.Height;
Config.Default.MainWindow_Width = e.NewSize.Width;

View file

@ -16,6 +16,11 @@
<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 a crashing bug when CSM closes and is unable to find the backup location to save the config settings.</li>
</ul>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>

View file

@ -16,6 +16,11 @@
<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 a crashing bug when CSM closes and is unable to find the backup location to save the config settings.</li>
</ul>
<u style="font-size: .9em;">NEW</u>
<br/>
<ul>

View file

@ -211,7 +211,7 @@ namespace ServerManagerTool
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState != WindowState.Minimized)
if (this.WindowState == WindowState.Normal)
{
Config.Default.MainWindow_Height = e.NewSize.Height;
Config.Default.MainWindow_Width = e.NewSize.Width;

View file

@ -47,18 +47,25 @@ namespace ServerManagerTool.Common.Utils
// do nothing, just exit
}
var filesToDelete = new DirectoryInfo(backupPath).GetFiles($"{settingsFileName}_*{settingsFileExt}").Where(f => f.LastWriteTimeUtc.AddDays(7) < DateTime.UtcNow).ToArray();
foreach (var fileToDelete in filesToDelete)
try
{
try
var filesToDelete = new DirectoryInfo(backupPath).GetFiles($"{settingsFileName}_*{settingsFileExt}").Where(f => f.LastWriteTimeUtc.AddDays(7) < DateTime.UtcNow).ToArray();
foreach (var fileToDelete in filesToDelete)
{
fileToDelete.Delete();
}
catch (Exception)
{
// do nothing, just exit
try
{
fileToDelete.Delete();
}
catch (Exception)
{
// do nothing, just exit
}
}
}
catch (Exception)
{
// do nothing, just exit
}
}
}