Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rounk-ctrl committed Sep 25, 2023
1 parent 3f7d984 commit 2d34609
Show file tree
Hide file tree
Showing 9 changed files with 537 additions and 489 deletions.
271 changes: 128 additions & 143 deletions Rectify11Installer/Core/Backend/Common.cs

Large diffs are not rendered by default.

169 changes: 85 additions & 84 deletions Rectify11Installer/Core/Backend/Extras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,98 +13,87 @@ internal class Extras
{
public static bool Install(FrmWizard frm)
{
Logger.WriteLine("Installing Extras");
Logger.WriteLine("─────────────────");

if (InstallOptions.InstallWallpaper)
{
frm.InstallerProgress = "Installing extras: Wallpapers";

if (InstallWallpapers())
Logger.WriteLine("InstallWallpapers() succeeded.");
}
if (InstallOptions.InstallASDF)
try
{
frm.InstallerProgress = "Installing extras: AccentColorizer";

if (Installasdf())
Logger.WriteLine("Installasdf() succeeded.");
Logger.WriteLine("Installing Extras");
Logger.WriteLine("─────────────────");

if (!Variables.RestartRequired)
if (InstallOptions.InstallWallpaper)
{
Interaction.Shell(Path.Combine(Variables.r11Folder, "extras", "AccentColorizer", "AccentColorizer.exe"), AppWinStyle.Hide);
Interaction.Shell(Path.Combine(Variables.r11Folder, "extras", "AccentColorizer", "AccentColorizerEleven.exe"), AppWinStyle.Hide);
frm.InstallerProgress = "Installing extras: Wallpapers";

if (InstallWallpapers())
Logger.WriteLine("InstallWallpapers() succeeded.");
}
}
if (InstallOptions.InstallGadgets)
{
frm.InstallerProgress = "Installing extras: Gadgets";
if (InstallOptions.InstallASDF)
{
frm.InstallerProgress = "Installing extras: AccentColorizer";

InstallGadgets();
Logger.WriteLine("InstallGadgets() succeeded.");
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "GadgetPack"), true);
}
if (InstallOptions.InstallShell)
{
frm.InstallerProgress = "Installing extras: Enhanced context menu";
Installasdf();

if (InstallShell())
Logger.WriteLine("InstallShell() succeeded.");
if (!Variables.RestartRequired)
{
Interaction.Shell(Path.Combine(Variables.r11Folder, "extras", "AccentColorizer", "AccentColorizer.exe"), AppWinStyle.Hide);
Interaction.Shell(Path.Combine(Variables.r11Folder, "extras", "AccentColorizer", "AccentColorizerEleven.exe"), AppWinStyle.Hide);
}
}
if (InstallOptions.InstallGadgets)
{
frm.InstallerProgress = "Installing extras: Gadgets";

try
InstallGadgets();
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "GadgetPack"), false);
}
if (InstallOptions.InstallShell)
{
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "Nilesoft"), true);
frm.InstallerProgress = "Installing extras: Enhanced context menu";

InstallShell();

Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "Nilesoft"), false);
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "NilesoftArm64"), false);
}
catch { }
try
if (InstallOptions.userAvatars)
{
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "NilesoftArm64"), true);
frm.InstallerProgress = "Installing extras: User avatars";

InstallUserAvatars();
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "userAV"), false);
}
catch { }
Logger.WriteLine("InstallExtras() succeeded.");
Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
if (InstallOptions.userAvatars)
catch (Exception ex)
{
frm.InstallerProgress = "Installing extras: User avatars";

if (InstallUserAvatars())
Logger.WriteLine("InstallUserAvatars() succeeded.");
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "userAV"), true);
Logger.WriteLine("Extras.Install() failed", ex);
return false;
}
Logger.WriteLine("InstallExtras() succeeded.");
Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
public static bool Uninstall()
{
for (int i = 0; i < UninstallOptions.uninstExtrasList.Count; i++)
try
{
if (UninstallOptions.uninstExtrasList[i] == "wallpapersNode")
{
UninstallWallpapers();
Logger.WriteLine("Uninstalled wallpapers");
}
if (UninstallOptions.uninstExtrasList[i] == "asdfNode")
for (int i = 0; i < UninstallOptions.uninstExtrasList.Count; i++)
{
UninstallAsdf();
Logger.WriteLine("Uninstalled asdf");
}
if (UninstallOptions.uninstExtrasList[i] == "useravNode")
{
UninstallUserAv();
Logger.WriteLine("Uninstalled user avatars");
}
if (UninstallOptions.uninstExtrasList[i] == "shellNode")
{
UninstallShell();
Logger.WriteLine("Uninstalled shell");
}
if (UninstallOptions.uninstExtrasList[i] == "gadgetsNode")
{
UninstallGadgets();
Logger.WriteLine("Uninstalled gadgets");
if (UninstallOptions.uninstExtrasList[i] == "wallpapersNode")
UninstallWallpapers();
if (UninstallOptions.uninstExtrasList[i] == "asdfNode")
UninstallAsdf();
if (UninstallOptions.uninstExtrasList[i] == "useravNode")
UninstallUserAv();
if (UninstallOptions.uninstExtrasList[i] == "shellNode")
UninstallShell();
if (UninstallOptions.uninstExtrasList[i] == "gadgetsNode")
UninstallGadgets();
}
return true;
}
catch (Exception ex)
{
Logger.WriteLine("Extras.Uninstall() failed", ex);
return false;
}
return true;
}

/// <summary>
Expand All @@ -117,8 +106,7 @@ private static bool InstallWallpapers()
UninstallWallpapers();

string path = Path.Combine(Variables.r11Folder, "extras", "wallpapers");
if (Directory.Exists(path))
Directory.Delete(path, true);
Helper.SafeDirectoryDeletion(path, false);

// extract the 7z
Helper.SvExtract("extras.7z", "extras", "wallpapers");
Expand All @@ -142,7 +130,9 @@ private static bool InstallWallpapers()
{
File.Copy(files[i].FullName, Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified", files[i].Name), true);
}
Directory.Delete(path, true);
Helper.SafeDirectoryDeletion(path, false);

Logger.WriteLine("InstallWallpapers() succeeded");
return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -173,10 +163,12 @@ private static bool Installasdf()
asdf11.Target = Path.Combine(Variables.r11Folder, "extras", "AccentColorizer", "AccentColorizerEleven.exe");
asdf11.Save(Path.Combine(GetFolderPath(SpecialFolder.CommonStartMenu), "programs", "startup", "Accentcolorizer11.lnk"));

Logger.WriteLine("Installasdf() succeeded.");
return true;
}
catch (Exception ex)
{
UninstallAsdf();
Logger.WriteLine("Installasdf() failed", ex);
return false;
}
Expand All @@ -190,10 +182,7 @@ private static void InstallGadgets()
try
{
UninstallGadgets();
if (Directory.Exists(Path.Combine(Variables.r11Folder, "extras", "GadgetPack")))
{
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "GadgetPack"), true);
}
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "GadgetPack"), false);

// extract the 7z
Helper.SvExtract("extras.7z", "extras", "GadgetPack");
Expand All @@ -206,9 +195,12 @@ private static void InstallGadgets()
};
var vcproc = Process.Start(gad);
vcproc.WaitForExit();

Logger.WriteLine("InstallGadgets() succeeded.");
}
catch (Exception ex)
{
UninstallGadgets();
Logger.WriteLine("InstallGadgets() failed", ex);
}
}
Expand Down Expand Up @@ -261,10 +253,13 @@ private static bool InstallShell()
Thread.Sleep(3000);
if (num == 4) Process.Start(Path.Combine(GetFolderPath(SpecialFolder.CommonStartMenu), "programs", "startup", "acrylmenu.lnk"));
}

Logger.WriteLine("InstallShell() succeeded.");
return true;
}
catch (Exception ex)
{
UninstallShell();
Logger.WriteLine("InstallShell() failed", ex);
return false;
}
Expand All @@ -278,11 +273,7 @@ private static bool InstallUserAvatars()
try
{
UninstallUserAv();

if (Directory.Exists(Path.Combine(Variables.r11Folder, "extras", "userAV")))
{
Directory.Delete(Path.Combine(Variables.r11Folder, "extras", "userAV"), true);
}
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "userAV"), false);

// extract the 7z
Helper.SvExtract("extras.7z", "extras", "userAV");
Expand All @@ -295,16 +286,18 @@ private static bool InstallUserAvatars()
File.Copy(Path.Combine(Variables.r11Folder, "extras", "userAV", info.GetFiles("*.*")[i].Name),
Path.Combine(Variables.progdata, "Microsoft", "User Account Pictures", "Default Pictures", info.GetFiles("*.*")[i].Name), true);
}

Logger.WriteLine("InstallUserAvatars() succeeded.");
return true;
}
catch (Exception ex)
{
UninstallUserAv();
Logger.WriteLine("InstallUserAvatars() failed", ex);
return false;
}
}


private static bool UninstallWallpapers()
{
try
Expand All @@ -331,6 +324,8 @@ private static bool UninstallWallpapers()
Helper.SafeDirectoryDeletion(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified"), false);
}
}

Logger.WriteLine("UninstallWallpapers() succeeded");
return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -365,6 +360,8 @@ private static bool UninstallAsdf()
{
Helper.SafeDirectoryDeletion(epath, false);
}

Logger.WriteLine("UninstallAsdf() succeeded");
return true;
}
return true;
Expand All @@ -384,6 +381,8 @@ private static bool UninstallGadgets()
var gaduns = Process.Start(uns);
gaduns.WaitForExit();
}

Logger.WriteLine("UninstallGadgets() succeeded");
return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -432,6 +431,7 @@ private static bool UninstallShell()
Thread.Sleep(3000);
}
}
Logger.WriteLine("UninstallShell() succeeded");
return true;
}
catch (Exception ex)
Expand All @@ -445,6 +445,7 @@ private static bool UninstallUserAv()
try
{
Helper.SafeDirectoryDeletion(Path.Combine(Variables.progdata, "Microsoft", "User Account Pictures", "Default Pictures"), false);
Logger.WriteLine("UninstallUserAv() succeeded");
return true;
}
catch (Exception ex)
Expand Down
Loading

0 comments on commit 2d34609

Please sign in to comment.