Skip to content

Commit

Permalink
Add error message if Updater fails to delete old YAMDCC installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparronator9999 committed Feb 23, 2025
1 parent 3947095 commit 864223a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Binary file removed YAMDCC.ECInspector/ec.ico
Binary file not shown.
35 changes: 25 additions & 10 deletions YAMDCC.Updater/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,35 @@ private static void InstallUpdate(

// delete the old YAMDCC installation
dlg.Caption = "Installing YAMDCC update...";
DirectoryInfo di = new(destPath);
foreach (FileInfo fi in di.GetFiles())
DirectoryInfo di;
try
{
fi.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
if (dir.FullName != confPath &&
dir.FullName != oldPath &&
dir.FullName != updatePath)
di = new(destPath);
foreach (FileInfo fi in di.GetFiles())
{
fi.Delete();
}
foreach (DirectoryInfo dir in di.GetDirectories())
{
dir.Delete(true);
if (dir.FullName != confPath &&
dir.FullName != oldPath &&
dir.FullName != updatePath)
{
dir.Delete(true);
}
}
}
catch (UnauthorizedAccessException ex)
{
Utils.ShowError(
"Failed to delete old YAMDCC installation.\n" +
"This probably means something else has YAMDCC's files open.\n" +
"See issue #62 on the YAMDCC GitHub for more info.\n\n" +
"Details:\n" +
$"{ex.GetType()}: {ex.Message}\n" +
$"{ex.StackTrace}");
return false;
}

// move updated YAMDCC into place
di = new(updatePath);
Expand Down

0 comments on commit 864223a

Please sign in to comment.