refactoring
This commit is contained in:
parent
d0743d66a0
commit
1fa39a3885
3 changed files with 19 additions and 41 deletions
|
@ -78,25 +78,9 @@ internal partial class InstallForm : CustomForm
|
||||||
foreach (string directory in await selection.GetKoaloaderDirectories())
|
foreach (string directory in await selection.GetKoaloaderDirectories())
|
||||||
{
|
{
|
||||||
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
||||||
bool proxyExists = false;
|
if (proxies.Any(proxy => File.Exists(proxy) && proxy.IsResourceFile(Resources.Resources.ResourceIdentifier.Koaloader))
|
||||||
foreach (string proxy in proxies)
|
|| Koaloader.AutoLoadDlls.Any(pair => File.Exists(directory + @"\" + pair.dll))
|
||||||
if (File.Exists(proxy) && proxy.IsResourceFile(Resources.Resources.ResourceIdentifier.Koaloader))
|
|| File.Exists(config))
|
||||||
{
|
|
||||||
proxyExists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
bool dllExists = proxyExists || false;
|
|
||||||
if (!dllExists)
|
|
||||||
foreach ((string unlocker, string dll) in Koaloader.AutoLoadDlls)
|
|
||||||
{
|
|
||||||
string path = directory + @"\" + dll;
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
dllExists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (proxyExists || dllExists || File.Exists(config))
|
|
||||||
{
|
{
|
||||||
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
|
UpdateUser("Uninstalling Koaloader from " + selection.Name + $" in directory \"{directory}\" . . . ", InstallationLog.Operation);
|
||||||
await Koaloader.Uninstall(directory, this);
|
await Koaloader.Uninstall(directory, this);
|
||||||
|
|
|
@ -72,8 +72,8 @@ internal partial class MainForm : CustomForm
|
||||||
if (checkForUpdatesResult.CanUpdate)
|
if (checkForUpdatesResult.CanUpdate)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
latestVersion = checkForUpdatesResult.LastVersion;
|
latestVersion = checkForUpdatesResult.LastVersion;
|
||||||
versions = checkForUpdatesResult.Versions;
|
versions = checkForUpdatesResult.Versions;
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,12 +18,11 @@ internal static class Koaloader
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
proxies = new();
|
proxies = new();
|
||||||
foreach (string proxy in Resources.EmbeddedResources)
|
foreach (string proxy in Resources.EmbeddedResources.Select(proxy =>
|
||||||
{
|
{
|
||||||
string proxyPath = proxy[(proxy.IndexOf('.') + 1)..];
|
proxy = proxy[(proxy.IndexOf('.') + 1)..];
|
||||||
proxyPath = proxyPath[(proxyPath.IndexOf('.') + 1)..];
|
return proxy[(proxy.IndexOf('.') + 1)..];
|
||||||
proxies.Add(directory + @"\" + proxyPath);
|
})) proxies.Add(directory + @"\" + proxy);
|
||||||
}
|
|
||||||
config = directory + @"\Koaloader.json";
|
config = directory + @"\Koaloader.json";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,24 +100,19 @@ internal static class Koaloader
|
||||||
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
|
internal static async Task Uninstall(string directory, InstallForm installForm = null, bool deleteConfig = true) => await Task.Run(() =>
|
||||||
{
|
{
|
||||||
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
directory.GetKoaloaderComponents(out List<string> proxies, out string config);
|
||||||
foreach (string proxy in proxies)
|
foreach (string proxy in proxies.Where(proxy => File.Exists(proxy) && proxy.IsResourceFile(Resources.ResourceIdentifier.Koaloader)))
|
||||||
{
|
{
|
||||||
if (File.Exists(proxy) && proxy.IsResourceFile(Resources.ResourceIdentifier.Koaloader))
|
File.Delete(proxy);
|
||||||
{
|
if (installForm is not null)
|
||||||
File.Delete(proxy);
|
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxy)}", InstallationLog.Action, info: false);
|
||||||
if (installForm is not null)
|
|
||||||
installForm.UpdateUser($"Deleted Koaloader: {Path.GetFileName(proxy)}", InstallationLog.Action, info: false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach ((string unlocker, string dll) in AutoLoadDlls)
|
foreach ((string unlocker, string path) in AutoLoadDlls
|
||||||
|
.Select(pair => (pair.unlocker, path: directory + @"\" + pair.dll))
|
||||||
|
.Where(pair => File.Exists(pair.path)))
|
||||||
{
|
{
|
||||||
string path = directory + @"\" + dll;
|
File.Delete(path);
|
||||||
if (File.Exists(path))
|
if (installForm is not null)
|
||||||
{
|
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", InstallationLog.Action, info: false);
|
||||||
File.Delete(path);
|
|
||||||
if (installForm is not null)
|
|
||||||
installForm.UpdateUser($"Deleted {unlocker}: {Path.GetFileName(path)}", InstallationLog.Action, info: false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (deleteConfig && File.Exists(config))
|
if (deleteConfig && File.Exists(config))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue